pointer problem

can anybody help me make a program that does this:

the program asks the user to enter an address(referring to integer address). The address is stored in a temporary int variable, and then copied to the integer pointer.

as of now all i can do is this

int x=8;
int *x_ptr= &x;


printf("Address of x: %p \n", x_ptr); //%p will give you the address
printf("Value of x: %d \n", *x_ptr);

pls help me...

the program asks the user to enter an address(referring to integer address). The address is stored in a temporary int variable, and then copied to the integer pointer.


*twitch*

This is an assignment? Who in their right mind would teach this?

Basically he's telling you to do this:

- get an integer from the user
- cast this integer to a int* and assign it to a int* (hint: don't use the & operator)


But UGH. Horrible, horrible, horrible.
i think you are searching for something like the following: http://cplusplus.com/forum/beginner/1777/
Topic archived. No new replies allowed.