Advertisement
Guest User

Untitled

a guest
Dec 6th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. declaration:
  2. char *a[6];
  3.  
  4. underlaying memory:
  5. | a[0] | a[1] | a[2] | a[3] | a[4] | a[5] |
  6.  
  7. and now you allocate 5 bytes for a[0]
  8. a[0] = malloc(5 * sizeof(char));
  9. | a[0] | a[1] | a[2] | a[3] | a[4] | a[5] |
  10. |
  11. v (some other region in memory)
  12. a[0][1] a[0][1] a[0][2] a[0][3] a[0][4]
  13.  
  14. is this so far more or less "correct"?
  15. or does memory looks like this after malloc operation?
  16. | 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