Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Dec 6th, 2018 69 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  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] |
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top