pointer memory location

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

int main()
{
  int a=10,b=5,*c,*d,**f;
  c=&a;
  d=&b;
  f=&d;
    printf("Address of a=%u\n",&a);
    printf("Address of b=%u\n",&b);
    printf("Address of c=%u \n",&c);
     printf("Address of d=%u \n",&d);
       printf("Address of d=%u \n",*d);

     printf("Address of f=%u \n");
    printf("About F \n %u\t%u \t%u \t %u",&c,f,*f,**f); 
           printf("Address store in c=%u \n",c);
    cout<<"\n *c++ ="<<*c++<<endl;//increase the adress store in pointer 
           printf("Address store in c=%u \n",c);
     printf("Address of a=%u\n",&a);
  
    printf("Address of c=%u \n",&c);
    
       printf("Address store in c=%u \n",c);
  
      a++;
    printf("%d \t %u \t %u \t %u\t",a,&a,c,&c);
     system("pause");
    }

cout<<"\n *c++ ="<<*c++<<endl;//increase the adress store in pointer variable
but when print the adress of int variable show different.

Adress of A & b

a=2293620
c=2293616

adress of a store in c=2293620
after increament
adress of a store in c=2293624

but adress of a =2293620
why?
Last edited on
*c++ doesn't mean "increase the address stored in the pointer". It means "advance the pointer to point to the next array element and read the value it used to point to"

You meant to write ++*c or (*c)++. See operator precedence: http://en.cppreference.com/w/cpp/language/operator_precedence
Last edited on
Topic archived. No new replies allowed.