#include <stdio.h> int main() { char a[] = {'C', 'H', 'i', 'n', 'a', '\0'}; //等价于 char a[] = "CHina"; printf("sizeof(a)=%ld\n", sizeof(a)); for (int i=0; i<sizeof(a); i++) { printf("%c\n", a[i]); } return 0; }
输出结果:
sizeof(a)=6 C H i n a
2024-01-20 10:32:22
#include <stdio.h> int main() { char a[] = {'C', 'H', 'i', 'n', 'a', '\0'}; //等价于 char a[] = "CHina"; printf("sizeof(a)=%ld\n", sizeof(a)); for (int i=0; i<sizeof(a); i++) { printf("%c\n", a[i]); } return 0; }
输出结果:
sizeof(a)=6 C H i n a
下一篇:K均值算法——应用