Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- declaration:
- char *a[6];
- underlaying memory:
- | a[0] | a[1] | a[2] | a[3] | a[4] | a[5] |
- and now you allocate 5 bytes for a[0]
- a[0] = malloc(5 * sizeof(char));
- | a[0] | a[1] | a[2] | a[3] | a[4] | a[5] |
- |
- v (some other region in memory)
- a[0][1] a[0][1] a[0][2] a[0][3] a[0][4]
- is this so far more or less "correct"?
- or does memory looks like this after malloc operation?
- | a[0][1] a[0][1] a[0][2] a[0][3] a[0][4] | a[1] | a[2] | a[3] | a[4] | a[5] |
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement