| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Managed C++ and C++/CLI Discuss Managed C++ and .NET-specific questions related to C++. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Assignment to structure value does not work
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 |
|
#2
|
|||
|
|||
|
Re: Assignment to structure value does not work
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/247referenc...44/222866.aspx ned. |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|