sizeof和strlen的测试demo

#include
#include

int main()
{
    char *p = "hello";
    int len1 = sizeof(p);
    int len2 = strlen(p);
    printf("len1 = %d,len2 = %d\n",len1,len2);

    char p1[] = "hello";
    int len3= sizeof(p1);
    int len4 = strlen(p1);
    printf("len3 = %d,len4 = %d\n",len3,len4);
 	
 	char p2[16] = "hello world";
    int len5= sizeof(p2);
    int len6 = strlen(p2);
    printf("len5 = %d,len6 = %d\n",len5,len6);


    return 0;
}

在这里插入图片描述

你可能感兴趣的:(c语言,c语言)