C Programming - Pointers - Discussion
Discussion Forum : Pointers - True / False Questions (Q.No. 4)
4.
Are the three declarations char **apple, char *apple[], and char apple[][] same?
Discussion:
43 comments Page 5 of 5.
Abhi said:
7 years ago
1 and 2 are same but 3 are 2D array.
Nanthagopal said:
6 years ago
For all the three cases memory allocation itself is different, doesn't anyone notice this.
apple[][] is fully allocated continuous memory locations.
*apple[] - the first dimension is continuously memory allocated whereas the second dimension is discrete pointers pointing random memory addresses.
**apple - here all the memory locations are randomly allocated.
apple[][] is fully allocated continuous memory locations.
*apple[] - the first dimension is continuously memory allocated whereas the second dimension is discrete pointers pointing random memory addresses.
**apple - here all the memory locations are randomly allocated.
(2)
Kodi said:
3 years ago
Yes, exactly it is the correct explanation.
char **apple - It is a double pointer,
char *apple[] -It is an array of pointers,
char apple[][]-It id 2-d array.
char **apple - It is a double pointer,
char *apple[] -It is an array of pointers,
char apple[][]-It id 2-d array.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers