#include <iostream>
int main(int argc, char* argv[])
{
int pt[4] = {'0','\0',0};
std::cout<<"size of pt: "<<sizeof(pt)<<std::endl;
std::cout<<"strlen of pt: "<<strlen((char*)pt)<<std::endl;
}
结果是:
size of pt: 16
strlen of pt: 1
当我 int pt[4] = {'0','\0',0};
改为int pt[4] = {'\0','0',0};
结果是
size of pt: 16
strlen of pt: 0
为什么?