Hi All

I just tried the following program
Code:
#include <stdio.h>
#include <string.h>

main() {
	char c[5] ;
	int x ;
	for( x= 0; x < 5; x++ ) {
			c[x] = 'c' ;
	}
	printf("\n%s l=%d\n", c, strlen(c)) ;

}
If I run this code it tells me the length of the array is 6!! Also when I let the loop go from 0 to 4 the length is still 6. What happened with the length of 5 ?

The result of the following example did also surprise me:
Code:
	char d[5] ;
	strcpy(d, "1234567890123" ) ;
	printf("\n%s l=%d\n", d, strlen(d)) ;
The length was 13, how is that possible. Interesting to say is that when I make that string 1 character longer the progrem executes, telling me the length is 14, but it ends with an segmentation fault

How is all this possible ?

Thnx a lot
LuCa