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 2 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.
"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).
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).
Sneha said:
1 decade ago
YES I do agree with RAM
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).
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.
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).
2 -----> apple[1][1]= *(*(apple+1)+1).
3 -----> from 1 and 2 apple[1][1] = *(apple[1] +1).
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers