I have the below code.
char a[] = "abcde";
char *b = "fghij";
char *c = malloc(6);
char *d = c;
c = "klmno";
And the exercise states:
Draw a picture of the data structures a, b, c and d(with content), where you can see what has been allocated and use arrows to show how pointers are set.
My solution is:
____________
a -> |a|b|c|d|e|\0|
¨¨¨¨¨¨¨¨¨¨¨¨
____________
b -> |f|g|h|i|j|\0|
¨¨¨¨¨¨¨¨¨¨¨¨
____________
c -> |k|l|m|n|o|\0|
¨¨¨¨¨¨¨¨¨¨¨¨
___________
d -> | | | | | | |
¨¨¨¨¨¨¨¨¨¨¨
However my solution did not get accepted and the response was "allocated memory for a pointer to b, c, d but not a". Can someone explain me what this means?