Search code examples
c++pointersdereference

How do i store the address of a variable and print the value using pointers


If for example i have a variable i=1. How do i store its address using pointers? the user would input the address of the variable then the program would return the variable, for example: int i=1 address for example is 221122 then the user inputs 221122 and the value to be returned should be 1. c++ is the language


Solution

  • int i;

    int *p;
    
    p=&i;
    
    now *p will give you the content in that address.