arrays - At which memory segment does pointer c+9 point for given function? -
void f() {int *c=(int*)malloc(10);}
void f() {int c[10];}
i think on in first case c+9
pointing @ element c[9]
in array allocated on heap.
and second case think c+9
pointing @ same element c[9]
of array located on stack.
i new programming , not sure if correct answer. help.
in both cases behaviour undefined. in case 1 points beyond allocated piece of memory. in case 2 points array allocated on stack , has been popped.
Comments
Post a Comment