Code::Blocks Forums
User forums => Help => Topic started by: kentut on May 22, 2014, 05:56:02 am
-
Hello guys, I am a new codeblocks user, and I really need it for debugging my program consisting of many functions. However, the watches windows can't show up the value of my array of char variable and char* variable. Anyone knows what's wrong with my codeblocks? I have attached the screenshot here.
Thanks guys :)
-
Here's screenshot of watches and my variable declaration..
-
I don't see any thing wrong. The local variable is not initialized, so random values are shown.
What is the expect value shown in the watch window?
-
Actually the previous screenshot is a called function, variable a and b are parameters passed from the main program, but I can't find the values.
Here's the screenshot in the main program. Although I have initialized b[0] and b[1], it doesn't show the value in watches.
-
Initialize b[0], b[1] to 0x30, 0x31 and try again please.
-
Here the screenshot after I set b[0] to 0x30 and b[1] to 0x31. The value still strange....
-
Actually there is nothing strange with the values. 0x30 is '0' and 0x31 is '1' and the first 2 characters of 'b' array correctly shows these values. The rest are some uninitialized random values which may not correspond to printable characters in ASCII table even when initialized to some value. So there doesn't seem to be anything wrong with the CB part.
-
char [] is the same as const char *, so gdb thinks it is a string and tries to print it as string. For function args and locals nothing could be done.
But if you want to inspect the variable as character array, then add it as a watch and right click -> properties -> treat as array (set start and count) and you're good to go.