天天看點

關于sizeof 和strlen 的用法

#include<stdio.h>

#include<string.h>

void sizeofApp(char * a)

{

    printf("%d %d %d\n",sizeof(a),sizeof(*a),strlen(a));

}

int main(void)

{

char str1[] = "1";

char str2[] = "11";

printf("sizeof(str1) = %d\n",sizeof(str1));

printf("sizeof(str2) = %d\n",sizeof(str2));

printf("strlen(str1) = %d\n",strlen(str1));

printf("strlen(str2) = %d\n",strlen(str2));

sizeofApp(str1);

sizeofApp(str2);

return 0;

}

繼續閱讀