sizeof 和strlen 的区别
#include <stdio.h>
#include <string.h>
main()
{
char x[30];
int a,i;
gets(x);
a=strlen(x);
printf("%d\n",a);
for (i=0;i<a;i++)
printf("%c\n",x[i]);
}
#include <stdio.h>
main()
{
char x[30];
int a,i;
gets(x);
a=sizeof(x)-1;
printf("%d\n",a);
for (i=0;i<a;i++)
printf("%c\n",x[i]);
}
理论上说,输出的应该是一样的啊 但是 用 sizeof为什么后面输出有一大串怪字符呢???
只有这点区别 但结果很大不同啊