hu...@cl... wrote:
> Hei all,
> whats the diference between this statements :
>
> int v[1000];
> memset(v,'\0',sizeof(v));
>
> and .....
>
> int v[1000];
> memset(v,0x00,sizeof(v));
Actually, nothing. 0x00 and '\0' means the same thing. 0x00 is simply 0
in decimal form. '\0' means the ascii-code of the \0 character (note:
NOT the ascii-code of '0') as far as I know, and it is also 0. So the
behaviour of the two memset's are identical.
It depends on the context which one is more appropriate. If you wish to
initialize a character buffer with the same characters, for example,
with the letter 'a', then the first form is more straight-forward:
char v[1000];
memset(v,'a',sizeof(v));
/* v[1000-1] = '\0' */
But in your case, the second is better, as you initialize an integer
array, and I suspect, that you wish to zero it out.
int v[1000];
memset(v,0,sizeof(v));
--
Greetings,
Balázs
|