#include <STDIO.H>
#include "string.h"
int main()
{
int x = 0;
char str[10] ;
// strlen()以'\0',作为结束标志,故strlen(str)不确定
x = strlen(str);
printf("strlen of str is: %d \n",x);
x = sizeof(str);
//而sizeof(str)==10
printf("sizeof of str is: %d \n",x);
char str2[] = "0123456789"; // 会自动添加一个结束符'\0'
// strlen()以'\0',作为结束标志,故strlen(str2)==10
x = strlen(str2);
printf("strlen of str2 is: %d \n",x);
x = sizeof(str2);
//而sizeof()则会把'\0'也计算在内,sizeof(str2)==10
printf("sizeof of str2 is: %d \n",x);
return 0;
}
#include "string.h"
int main()
{
int x = 0;
char str[10] ;
// strlen()以'\0',作为结束标志,故strlen(str)不确定
x = strlen(str);
printf("strlen of str is: %d \n",x);
x = sizeof(str);
//而sizeof(str)==10
printf("sizeof of str is: %d \n",x);
char str2[] = "0123456789"; // 会自动添加一个结束符'\0'
// strlen()以'\0',作为结束标志,故strlen(str2)==10
x = strlen(str2);
printf("strlen of str2 is: %d \n",x);
x = sizeof(str2);
//而sizeof()则会把'\0'也计算在内,sizeof(str2)==10
printf("sizeof of str2 is: %d \n",x);
return 0;
}