char, char*,scanf,printf

来源:互联网 发布:计算机中的数据是指 编辑:程序博客网 时间:2024/04/27 17:15
int main(){char c = '\n';char d = '\0';char e = 0;char f = '0';printf("%d\n",c);//10printf("%d\n",d);//0printf("%d\n",e);//0printf("%d\n",f);//48char *p = new char[10];//ok//char p[10];//ok//char *p;//must be initializedscanf("%s",p);//end by typing '\n' or ' ',but this '\n' or ' 'is not counted in pint cnt = 0;char *q =p;//while(q)//wrong//while(*q != '\n')//wrong//while(*q != 0)//ok//while(*q != '\0')//ok '\0' equals 0while(*q)//ok{cnt++;q++;}printf("%d\n",cnt);delete []p;return 0;}

0 0
原创粉丝点击