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]
# 1 Re: Data lost
There must be some part of your code that erases the first part of your structure. Check your code, especially those that use pointers. Maybe they are pointing to a address the same with the structure's address.

Hope it will help you.
rxbagain at 2007-11-11 2:53:29 >
# 2 Re: Data lost
you mean a pointer pointing to this structure? there's no pointer for this struct.
Amyeech at 2007-11-11 2:54:30 >
# 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
AsmCoder8088 at 2007-11-11 2:55:28 >
# 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
rxbagain at 2007-11-11 2:56:27 >
# 5 Re: Data lost
MAX_TAGS is 600

not sure if this is too big??
Amyeech at 2007-11-11 2:57:37 >
# 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
AsmCoder8088 at 2007-11-11 2:58:30 >
# 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?
Amyeech at 2007-11-11 2:59:34 >
# 8 Re: Data lost
Could you please show the code for this function? Without further information, all I can say is that the other structure makes some reference to Tagcfg.

Thanks,

Daniel
AsmCoder8088 at 2007-11-11 3:00:38 >