[腾讯]sizeof()和strlen()的区别

来源:互联网 发布:自行车风火轮如何编程 编辑:程序博客网 时间:2024/06/03 10:48

下面程序的输出:

#include <iostream>#include <string>#include <vector>using namespace std;void Func(char str_arg[100]){    printf("%d\n", sizeof(str_arg));}int main(void){    char str[] = "Hello";    printf("%d\n", sizeof(str));    printf("%d\n", strlen(str));    char *p = str;    printf("%d\n", sizeof(p));    Func(str);}

输出:

6 5 4 4

0 0