Data lost
Hi,
I have declared this struct in my stdafx.h
typedef struct Tag_Config
{
char tag[MAX_TAGS][100];
}TagConfig;
And declared TagConfig Tagcfg in my main.h
At initialization, I read some data from my excel into this structure and the data appears to be correct.
I didn't used this structure anywhere else in the program.
At termination, I read this structure again, the first 7 data is empty but the rest are ok.
Why is this happening? Any help is much appreciated. Thank you in advance.
:(
[575 byte] By [
Amyeech] at [2007-11-18 7:54:53]

# 3 Re: Data lost
How large is MAX_TAGS (if not certain, give estimate or range)? It is possible that you are exceeding a memory restraint in some way.
Also, do a search in your code to find references to "Tagcfg". After each reference, display the contents of this memory block, and once you come across a point where the data are deleted, you know where you have found the cause.
Hope this helps,
Daniel
# 4 Re: Data lost
I mean other pointers that you use. For example, you have a char *, and u mistakenly place an address to this variable that can affect the structure. And then you issued some memset or other commands that will clear the memory pointed by that char* affecting the structure.
Another reason is that you may have declared for example a char[100] before the structure and the you use memset with 800 as the size. In this case it will erase the 700 bytes of the structure since the char[100]'s size is only 100.
Hope it will help you
# 6 Re: Data lost
That should not be too large... Like I said earlier, though, try placing some code in each spot where a reference is made to the structure and comparing the length of the data. Once a change is made, you will know where it occurred. This is how I fix a lot of my bugs; using message boxes.
Hope this helps,
Daniel
# 7 Re: Data lost
I have realised that my struct content changes when one function is running.
This function has another different typedef struct inside. When I disable copying of this struct, the Tagcfg has no problem.
Could it be a memory overlap?