Originally Posted by
matthayzon89
So, once it breaks it up into parts, how is it successful in accessing a whole string via 1 array slot?
Perhaps an example will illustrate the idea:
Code:
#include <string.h>
#include <stdio.h>
int main(void)
{
char strings[12];
strcpy(&strings[0], "hello");
strcpy(&strings[6], "world");
printf("%s\n%s\n", &strings[0], &strings[6]);
return 0;
}
Of course, this is quite silly, but it does have a sensible practical application: maybe you want a dynamic 2D array. You could have a dynamic array of pointers, and then allocate a dynamic array for each pointer. Or, you could allocate one big dynamic array, and then allocate another dynamic array of pointers, and then get those pointers to point to the parts of this one big dynamic array, and thus be able to access it as if it were a "normal" 2D array. Ultimately, a "normal" fixed size 2D array is also one fixed size array that the compiler has divided for you.