Part of the answer refers to GPT, GPT_Pro better solve the problem
A: This is an interesting problem. The Codeblock debugger actually has a problem with the memory order of variables. It should be storing a and ch in the wrong place. We know that in C language, variables are red in memory from low to high address. That is, the variables defined first should occupy the lower address space in memory, and the variables defined later should occupy the higher address space.
Let's look at the problem with Codeblock17 12debug. The first red box is four bytes of a, the second red box is one byte of ch, and the middle 32 00 00 should be the control byte. As can be seen from here, in fact, the memory storage locations of a and ch are reversed, which should be defined as a at the low address and ch at the high address.
To solve this problem, we can modify the memory order through the code. We can use the C language malloc function to do this. For example:
int *a = (int *)malloc(sizeof(int));
char *ch = (char *)malloc(sizeof(char));
Using the malloc function to separate a and ch memory space, can normally define the variable memory order.
If the answer is helpful, please accept it.