Jump to content
Sign in to follow this  
Getz

Guna Malloc Utk Mutidimensional Array

Recommended Posts

Assalamualaikum...

Camne agaknya cara nak pakai malloc utk multidimensional array?

Boleh tak tlg terangkan?

Initially aku ada satu array str[32][],

Yg dimension kat belakang tu aku nak tunggu input n drp user,

pastu baru aku nak pakai malloc utk set balik size array tu kpd str[32][n],

Harap tolong biggrin.gifbiggrin.gifbiggrin.gif

TQ

Share this post


Link to post
Share on other sites

for 2 dim..

char **x;

x = (char **)malloc(SIZEWANTED);

for(i=0;i<SIZEWANTED;i++)

*(x+i) = (char *)malloc(BUFLEN);

*(x+i) = 0;

gitu jugak dgn dim: 3, 4, 5...

art of free() tu aku tak braper jelas nak terangkan, nanti saya baca balik

Edited by fatah

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...