Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!hplabs!hpcc05!hpcuhb!hpda!hpwala!hp-and!gallag@hpanui.HP.COM From: gallag@hpanui.HP.COM (Mike Gallagher) Newsgroups: comp.lang.c Subject: Re: Structure hopping Message-ID: <13530004@hpanui.HP.COM> Date: 3 Jan 91 23:07:34 GMT References: <949@tfsg.UUCP> Organization: HP Andover Division (Massachusetts) Lines: 22 > dump a structure to a file (or whatever) using pointers, if we > I would LIKE to be able to do something like this: > char *struct_ptr; > struct_ptr = mr_structure > while (struct_ptr != "whatever it is that signals the end of a structure") { > putc (*struct_ptr, fp); > } Try this: char *struct_ptr, *end_ptr; struct_ptr = (char *)&mr_structure; /* ^ note the missing & above */ end_ptr = struct_ptr + sizeof(mr_structure); while (struct_ptr != end_ptr) { putc (*struct_ptr++, fp); } Mike