#include<stdio.h>
void main()
{
char s[]="\0";
printf("%d - %d\n",printf("%s",s),sizeof(s));
}
Output:
0 - 2
ConCept:
Printf stops printing when it meets '\0', it can't print '\0'. For reference, see No. 4. But why size of s is 2. Because when string is defined compiler automatically places a '\0' in the end of string. So string 's' is actually {'\0','\0'} .
void main()
{
char s[]="\0";
printf("%d - %d\n",printf("%s",s),sizeof(s));
}
Output:
0 - 2
ConCept:
Printf stops printing when it meets '\0', it can't print '\0'. For reference, see No. 4. But why size of s is 2. Because when string is defined compiler automatically places a '\0' in the end of string. So string 's' is actually {'\0','\0'} .
No comments:
Post a Comment