Hi,
To understand the C declaration and Pointers i have written the following sample code but not able to understand the output
#include <stdio.h>
int x[10] = { /* array of 10 integers */
2,2,2,2,2,2,2,2,2
};
int (y)[10] = { /* array of 10 integers */
1,2,3,4,5,6,7,8,9
};
main(){
int (*px)[10], (*py)[10]; /* px and py declared as pointer to array 10 of integers
px = &x; /* px is assigned x address*/
py = &y; /* py is assigned y address */
printf("x=%d, y=%d",*px,*py);
}
iam always getting the output x=404, y=464. is it possible for me to get the initial values of x and y i.e., 2 and 1?
another clarification is if i declare a pointer such as px which is pointing to array 10 of integers can i initialize the px pointer to an array of different size?
Thanks in advance.
To understand the C declaration and Pointers i have written the following sample code but not able to understand the output
#include <stdio.h>
int x[10] = { /* array of 10 integers */
2,2,2,2,2,2,2,2,2
};
int (y)[10] = { /* array of 10 integers */
1,2,3,4,5,6,7,8,9
};
main(){
int (*px)[10], (*py)[10]; /* px and py declared as pointer to array 10 of integers
px = &x; /* px is assigned x address*/
py = &y; /* py is assigned y address */
printf("x=%d, y=%d",*px,*py);
}
iam always getting the output x=404, y=464. is it possible for me to get the initial values of x and y i.e., 2 and 1?
another clarification is if i declare a pointer such as px which is pointing to array 10 of integers can i initialize the px pointer to an array of different size?
Thanks in advance.