When declaring a variable, are they stored next to each other? So for example would this show values of b and d?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
usingnamespace std;
int main()
{
int a=7;
int b=6;
int c=5;
int d=4;
int f=3;
int* p = &c;
cout << *(p+1) << endl;
cout << *(p-1) << endl;
}
Or is it necessary to declare pointers of other variables in order to.. make stuff work? If so, why? And why in that case *(p-1) would point to 0?