Friday, 13 September 2013

size of char is not consistent between an array and string

size of char is not consistent between an array and string

if you have
char test1[] = { 'a', 'b', 'c' };
char test2[] = "abc";
I understand sizeof(test1) is 3 since char is only 1 byte hence 1x3 = 3
BUT why isnt the sizeof(test2) 3? y is it 4?

No comments:

Post a Comment