This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

string definition

I have following code but find that x and y are the same value on the debugger. viewing ARM assembly review that the memcpy use same string address.

#define A "\xA0\x00\x01"
#define B "\xA0\x00\x02"
memcpy(x, A, sizeof(A)-1);
memcpy(y, B, sizeof(B)-1);

If I change
#define A "\xA0\x01\x01"
#define B "\xA0\x02\x02"
it will be OK.

Tam

Parents
  • Tam,

    I'm guessing that the debugger is assuming that you want to look at these variables as NULL-terminated strings. This means that it figures anything after the first null (0x00) character is just junk in memory that you don't want to see. They look the same in the first example because they ARE the same up to the first null character. In the second, you got rid of the null, so they appear different. If you look directly at memory, you'll probably see what you expect.

Reply
  • Tam,

    I'm guessing that the debugger is assuming that you want to look at these variables as NULL-terminated strings. This means that it figures anything after the first null (0x00) character is just junk in memory that you don't want to see. They look the same in the first example because they ARE the same up to the first null character. In the second, you got rid of the null, so they appear different. If you look directly at memory, you'll probably see what you expect.

Children
No data