Dear Users,
please consider the followin piece of C code:
1 -#include <stdio.h>
2 -#include <stdlib.h>
3 -#include <string.h>
4 -
5 -struct reg{
6 - char name[80];
7 - char phone[20];
8 -};
9 -
10-int main()
11-{
12- struct reg mydata;
13-
14- strcpy(mydata.name, "test name");
15- strcpy(mydata.phone, "test phone");
16- printf("%s\n", mydata.phone);
17-
18- system("PAUSE");
19- return 0;
20-}
1)Using the step-by-step execution together with variable inspection on
the "Debug"
window, it isn´t showed the copy on line 15, that is, mydata.phone is
still showing
garbage on the "Debug" window;
2)But the printf on line 16 confirms that the new value, "test phone" is
there ok;
3)Every kind of struct or pointer struct, of any size, is presenting the
same
behavior: the last field is not updated by the respective command on
the "Debug" window,
but the right value is there!
4)Dev-C 4.9.8.0
QUESTION: What is happening? Can anybody explain me?
Thanks in advance
Andre
|