- #include <stdio.h>
- int main()
- {
- char a[]={"abcdef"};
- char b[]={'h','i','j','k'}; //此数组长度自动为4
- char c[]="abcdef";
- char d[6]={"abcdef"}; //由于数组长度限制为6,没办法在第七个自动加字符'\0'
- printf("a[]=%s\tb[]=%s\tc[]=%s\td[]=%s\n",a,b,c,d);
- printf("a[]数组的字节数为:%lu\n",sizeof (a));
- return 0;
- }
复制代码
|
|