C语言-杂记

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/s1162276945/article/details/81276945

2N 要表示为 2*N
printf(“%d”, a) 引号必须是双引号,不能是单引号,否则报:

error C2664: 'printf' : cannot convert parameter 1 from 'const int' to 'const char *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

从键盘输入字符串:
scanf(“%s”,s);
拍入how are you, s 只读到how. 因为默认 空白 是分隔符。
printf(“%d”,strlen(s)); 打出 3

定义的字符串,包括空格。strlen 假定字符串结束符是 “\0”, 但总长度不计入”\0”这个字符。
char s[]=” how are you”;
printf(“%d”,strlen(s)); // 含字符串和空白个数

猜你喜欢

转载自blog.csdn.net/s1162276945/article/details/81276945