Hi. How does an array get stored?
say
char array[ ] = "linux";
array[0] is 'l'
array[1] is 'i'
etc,
but is there a '\0' in the 5th cell or EOF
Question arises cause I got a segmentation fault in the following>
char array [ ] = "linux";
for( i = 0; i != '\0'; i++)
printf("array[%d] contains %c\n", i, array[i]);
the output just kept printing a long list of array contents to stdout and ended saying segmentation fault
I probably am not checking for EOF correctly in the 'for' loop.
Say char array[10] was to be filled in by the program asking user for input?
I would'nt want to print the contents of all the cells he or she didnt fill ( say if user only types name 'Bill' into the array) How ... using the 'for' loop would I check to stop 'i' from further augmenting at end of the array?
I thought it was 'i != '\0' ' or i != EOF
Can someone help?
thanks