after my question yesterday about passing a 2d string array to a function i thought i had better go back and review the chapter on pointers.
Code:
int main()
{
int x, y;
int *p_x = &x, *p_y = &y; // declare pointers to x and y
x = 5;
printf("x = %d\n", x);
printf("p_x = %X\n", *p_x);
*p_x = 9; // makes x = 9
printf("x = %d\n", x);
printf("p_x = %X\n", *p_x);
y = 3;
*p_x = *p_y; // makes x the value of y
y = 6;
printf("p_x = %X\n", *p_x);
p_x = p_y; //assigns the address of y to the pointer p_x
printf("p_x = %X\n", *p_x);
return 0;
the comments are what i got when the program ran not what i expected to get.
question is if i have to designate a pointer by putting an astrix in front of the variables name ie *p_x rather than p_x how come when you use the point like in the above examples its the opposite.
many thanks
coop