2011年5月23日星期一

  Difference between "\0" and '\0' and '0' and 0

To me, when doing C/C++:
0 would digit zero, that is, a numerical value.
'0' could be the character capital oh or the character zero. For example:
char word[10] = "Oxford";
char number[10] = "01234";
Depending on typeface used 'O' may look exactly like '0' making it difficult to tell them apart out of context.

'\0' is the null character used to terminate strings in C/C++. 这里是用转义字符的八进制表示的'\ddd'

'\0' = 0 =0x00=000= '\x00'='\000'  = NULL

"\0" is an empty string.  strlen("\0" ) = 0  "\0" 是空字符串,并不包任何字符,因为字符串就是以null character '\0'作为结束的

16进制常整数 0x开头 如:0xff

8进制常整数   0开头    如:0ff

 

printf("%sb\n","\0");
printf("%d\n",strlen("\0"));

image

没有评论:

发表评论