Thursday, October 16, 2008

0 is same as '\0'

void main(){
char check[10];
check[0] = 'a';
check[1] = 'b';
check[2] = 0;
printf("%s\n",check);
}
will produce the same output as :

void
main(){
char check[10];
check[0] = 'a';
check[1] = 'b';
check[2] = '\0';
printf("%s\n",check);
}

since ascii code of '\0' is 0,
whereas ascii code of '0' is 48.

No comments:

Blog Archive