Thanks to all for the suggestions and apologies for posting c**p code. I didn't want to post hundreds of lines of real code and came up with a buggy example :-(
The alignment problem looks to be...
Type: Posts; User: freebu
Thanks to all for the suggestions and apologies for posting c**p code. I didn't want to post hundreds of lines of real code and came up with a buggy example :-(
The alignment problem looks to be...
Sorry - didn't make myself clear enough.
Assume you can't change the code I posted, but I need a pointer to the place in the buffer where the stored struct starts.
Is this legal ??
ptr =...
What's the correct way to do pointer arithmetic in this example ?
Say I store a struct in a buffer at some offset and then want to get a pointer to it. e.g.
int offset;
sometype...
Yeah, fseek() returns 0 (zero) for success and -1 on error.
You *really* should get into the habit of checking return values. Something like:
if (fseek(fp, 0L, SEEK_SET) != 0) {
//...
If you're trying to read back what you've just written, you'll have to "rewind" the file pointer first of all.
After the fprintf(), the file pointer will be positioned at the end-of-file - just...