+ 1

What will happen if C++ Pointer variable is increment?

If i increment an int type of pointer variable then what will increment? The value that it point to? Or the memory size? Answr Please! Example : int a=5; int *ptr; ptr=&a; ptr++; cout<<*ptr; What will be the value of " *ptr " and How ????

25th Nov 2017, 5:26 AM
Waqas Ahmed
Waqas Ahmed - avatar
1 Answer
+ 7
just next memory and then cout <<*ptr; will print garbage value out since the next address of ptr isn't assigned yet
25th Nov 2017, 5:31 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar