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

Shemonti said:   1 decade ago
But char *apple[] and char apple[][] both denote 2D array.like we can declare char *apple[]={"mango",
"grapes",
"jack fruit"};

And char apple[3][10]={
"mango",
"grapes",
"jack fruit"};

Both will give same result.

Patil said:   10 years ago
1. **a = *(*(a+0)+0) = a[][].

2. *a[] = *(*(a+0)+0), where a[] = *(a+0).

2.1 *a[] = **(a+0) or,

2.2 *a[] =*(*(a+0)+0).

Above 2.1 and 2.2 both are same are different.

3. Apple[][] = *(*(a+0)+0).

Prabal said:   10 years ago
You can't increment an array as for:

apple[][] you can't do apple++.

*apple[] you can't do apple++.

**apple you can do apple++.

Simply array variable acts as a pointer but we can't modify it to point to another location in case of apple++ in apple array variable. We can do apple+1 but doing apple = apple+1 would give an error.

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

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

Larry said:   9 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).

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

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

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

Shusec said:   7 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).


Post your comments here:

Your comments will be displayed after verification.