Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!tfsg!mark From: mark@tfsg.UUCP (Mark Crafts) Newsgroups: comp.lang.c Subject: Structure hopping Message-ID: <949@tfsg.UUCP> Date: 2 Jan 91 21:01:05 GMT Reply-To: mark@tfsg.UUCP (Mark Crafts) Organization: TRW Inc, Chantilly VA Lines: 38 Forgive my ignorance, but is there a quick 'n' simple way to say, dump a structure to a file (or whatever) using pointers, if we know that the structure only consists of, (for example) chars? I would think that you could assign a pointer to the beginning of the structure, and (assuming structures are set up linearly) hop down the list. This question also brings up another one... if this can be done, how do we know when to stop aside from hardcoding a certain number of iterations? For example, assume we have a structure like this: struct grandpa_structure { char data1[30]; char data2[23]; . . . char data95[12]; }; struct grandpa_structure mr_structure; In other words, a structure that would be really annoying to write out one field at a time. I would LIKE to be able to do something like this: (assume mr_structure to be filled in somehow) char *struct_ptr; . . struct_ptr = mr_structure while (struct_ptr != "whatever it is that signals the end of a structure") { putc (*struct_ptr, fp); } All responses are appreciated. Mark