GeeksforGeeks » C/C++ Programming Questions
Why does this program give error?
(3 posts)-
#include<stdio.h> int main() { int x[10]; int (*p)[10]; p = x; getchar(); return 0; } -
I think you cant direct assign a integer array to pointer unlike character array, try p = &x. This will work I believe.
-
yes, the following program works.
#include<stdio.h> #include<stdio.h> int main() { int x[10] = {12, 13, 14}; int (*p)[10]; p = &x; printf("%d", (*p)[0]); getchar(); return 0; }Thanks :)
Reply
You must log in to post.