Friday 15 March 2013

pointers - Loop thorough **variable in C -



pointers - Loop thorough **variable in C -

i have pointer of pointers, , want loop go thorough them , store value else. there way that?

e.g:

char **variable;

now want read variable:

char **variable2

i thought of doing this:

for(i = 0;i <length_of_variable-1;i++){ variable2[i] = variable[i+1] }

but not possible in c, right?

now might inquire why not variable2 = variable? variable2 should store parts of variable, not of them. edit: variable's size not known, , dynamic(read command line). , no doesn't contain '\0' @ end. cause processed remove such character , passed function implementing.

if putting **variable, mean have allocated memory correctly? think improve revise , understand how simple 1 dimensional array works, after understanding that, move double arrays. take how pointers work , larn how allocate memory. after understanding steps have mentioned above, take @ double pointers , allocation of memory in case of double pointers. here go.

c pointers 2d

No comments:

Post a Comment