Friday, August 30, 2013

Is char a[3] = "abc"; legal?

It declares an array of size three, initialized with the three characters 'a', 'b',
and 'c', without the usual terminating '\0' character. The array is therefore not
a true C string and cannot be used with strcpy, printf %s, etc. But its legal. 

No comments:

Post a Comment