Malloc + 2d arrays + C
Giannis Papaioannou
jhn at egnatia.ee.auth.gr
Tue Mar 26 17:47:01 EET 2002
On Fri, 22 Mar 2002, Peter Pissias wrote:
>exw thn entypwsh pws gia na kaneis ena allocate
>tou styl char** = malloc .....
>1) Xreiazetai prwta na kaneis allocate tous pointers
>int x = ...
>char** temp = malloc(x * sizeof(char*) );
>kai meta :
>2)
>for ( ... )
>{
> temp[i] = malloc(y * sizeof(char) );
>}
>kai meta antistrofa free .
Sto poly wraio paradeigma tou vasili mporei kaneis na dei pws ginete me
mono dyo malloc, mia gia enan index array kai mia gia olh thn mnhmh pou 8a
xreiasteis (x*y), arkei na peraseis tis 8eseis mnhmhs opou isxiei y=0 ston
index array.
More information about the Linux-greek-users
mailing list