char * test = "test";
cout << sizeof(test);
char test2[] = "test";
cout << sizeof(test2);
Running this on visual studio 2010, why is the output 45
?
Shouldn't test be a string literal and the sizeof
a string literal be the number of character elements in the string literal including the terminating null character?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…