c++ sizeof分别获取指针、引用、数组的长度

gy2006_sw

关注

阅读 184

2022-02-17

    char* p = new char[500];    
    char& a = *p;
    int l1 = sizeof(p);   //4
    int l2 = sizeof(a);   //1
    int l3 = sizeof(*p);  //1
    int l4 = strlen(p);   //不固定 到'\0'为止
    ZeroMemory(p, 500);   //
    int l5 = strlen(p);   //0

    char p2[500];
    int l6 = sizeof(p2);//500
 

精彩评论(0)

0 0 举报