Click to See Complete Forum and Search --> : Assignment to structure value does not work


Nina Donath
July 29th, 2005, 11:07 AM
I have a C++ .NET project.

In a .h file I use for global #defines and definitions, I have the following:

typedef struct _mini
{
int iVal;
} miniStruct;

typedef struct _test
{
miniStruct mini[10];
} testStruct;



At the beginning of the Form Load function :

testStruct teststr;

teststr.mini[0].iVal = 11;
teststr.mini[1].iVal = 22;

Can someone tell me why the 2nd array value (i.e. teststr.mini[1].iVal) does not get assigned to 22? It is always 0. It is driving me crazy.

Thanks for any insight you can give,

nina

Nina Donath
August 2nd, 2005, 12:43 PM
No one in this forum posted a reply about this problem I was having, but I now have a solution, which I will share mostly to save someone else from 3 days of anxiety.

I ended up posting this problem to another users group and someone said, if you convert teststr.mini[1].iVal to a string and display it in a message box, it shows the value of 22, so what was the problem?

Well, he was right. I then explained that going through the debugger - Quickwatch or the cursor placed over teststr.mini[1].iVal always displayed 0. Why?

Explanation: A bug in the Microsoft debugger! ARGGG The following link explains it:


http://www.dotnet247.com/247reference/msgs/44/222866.aspx

ned.