Original Post
I am just debugging some code I have written and have noticed that some of my output isn''t what I would expect.
I have a struct called Header that contains various bits of info in a file header. When the header is created I can watch my variables get assigned to the values I want, then one of them gets changed by another line of code without actually being referenced. I assume it''s a memory / address problem, and it is something I am doing, but can anyone see what and tell me how to get round it ?
I have gone into the code and monitored it line by line, and it is definitely the strcpy that is doing this. As an experiment I tried doing the same thing with a buffer area (see the lines above) and that doesn''t seem to have the same problem, but why should using an intermediary in this manner solve my problem ?
TIA
Bp
//Write Data to the File Structure Header Header.cMajorV = intVersionMajor; Header.cMinorV = intVersionMinor; char *buffer; strcpy(buffer, "F"); Header.cFlags = *buffer; //Somehow, this code is Overwriting cMajorV strcpy((char*)Header.cSignature, "DATA");