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 3 of 5.

Mrutyunjay said:   1 decade ago
char **apple - Pointer to pointer to a character
char *apple[] - An array of pointer to a character
char apple[][]- It is 2 dimensional array

Sneha said:   1 decade ago
YES I do agree with RAM

Susil said:   1 decade ago
Ya pooja and Mrutyunjay are correct.

Hariom said:   1 decade ago
char **apple is pointer of pointer.

Anil said:   1 decade ago
char **apple -----------> This is Double Pointer
char *apple[] -----------> This is Array Pointer
char apple[][] -----------> This is 2D Array

Manjunath said:   1 decade ago
See both are proper.

char **apple -----------> This is Double Pointer
char *apple[] -----------> This is Array Pointer
char apple[][] -----------> This is 2D Array

As well as,
**a
or
*a[]
or
**a[]
are the same statement.

It works according to the way you use.

Ex: char *p and char p[] both are same and both indicates string.
Similarly all above statements are same.

BDS said:   1 decade ago
char **apple ------>Its a double Pointer.

char *apple[] -------->Array of Pointers.

char apple[][] ---------->2D Array.

Ashwini said:   1 decade ago
char **apple - double pointer.
char *apple[] - array of pointers.
char apple[][] - 2D array.
char (*apple)[5] - pointer to an array of 5 characters.

Pranav kumare said:   1 decade ago
All three can be used to initiate a 2D array of character i.e string.

But here **apple indicates that this is a pointer to a char pointer.

*apple[] indicates that this is an array of pointers.

apple[][] indicates that this is an 2D array of characters i.e string;

Iceberg said:   1 decade ago
@pranav
2D array of character is not string , string is 1D array.
char * is a string. or char str[] is a string.
2D array will be a para. where each line is a string, rem string can have white space.
For the ques above. their name or notation are different , but all of them are mostly used to indicate a 2d array. but they can be used for different pupose too. so they are different.


Post your comments here:

Your comments will be displayed after verification.