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?
True
False
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
43 comments Page 1 of 5.

Kodi said:   2 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.

Nanthagopal said:   5 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.
(2)

Abhi said:   6 years ago
1 and 2 are same but 3 are 2D array.

Shusec said:   6 years ago
1 -----> apple[1] = *(apple +1).
2 -----> apple[1][1]= *(*(apple+1)+1).
3 -----> from 1 and 2 apple[1][1] = *(apple[1] +1).

Shubham Singh said:   6 years ago
Are apple , *apple[] , **apple[][] equal ?

Hari said:   7 years ago
You are right @Pooja.

RAYA said:   8 years ago
char **apple -----------> This is Double Pointer.
char *apple[] -----------> This is Array Pointer.
char apple[][] -----------> This is 2D Array.

Larry said:   8 years ago
1 -----> apple[1] = *(apple +1).
2 -----> apple[1][1]= *(*(apple+1)+1).
3 -----> from 1 and 2 apple[1][1] = *(apple[1] +1).

Shanthi said:   8 years ago
Yes, these three are different from each other, no one is similar.

Rahul kumar ojha said:   9 years ago
I think all are not same in some aspect but they can work same.


Post your comments here:

Your comments will be displayed after verification.