Re: Problem with VS and memcpy...

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Why 0 is the same as \0?
So I can't enter 0 in an array of char?

John Carson ha scritto:

"Paolo" <paomic@xxxxxxxxx> wrote in message
news:1151575114.297220.27410@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
The excat code is:


int number = 25;
int offSet = 16000;
unsigned char header[8];
header[0] = 0;

Just as I thought. Entering 0 as a character is the same as entering '\0'.
Thus header has a terminating nul character as its first character.
Accordingly, "" is the correct representation.

header[1] = 255;
header[2] = 0;
header[3] = number>>8;
header[4] = number;
header[5] = offSet>>16;
header[6] = offSet>>8;
header[7] = offSet;

memcpy(buffer, header, sizeof header);


--
John Carson

.



Relevant Pages