Please explain the output of the last line of the code. Why 0x23fe3a when short is of 2 bytes? And why 0x23fe36 after 0x23fe3a? The output is :
0x23fe34
0x23fe36
0x23fe3a 0x23fe36 0x23fe3a
#include<iostream>
using namespace std;
int main()
{
short num=77;
short* sptr = #
cout<<"Pointer to short"<<endl;
cout<<sptr-1<<endl<<endl;
cout<<sptr<<endl;
cout<<++sptr<<" "<<sptr++<<" "<<sptr<<endl;
}
But If I break the last line into two lines as below, I get the correct output. which is
0x23fe34
0x23fe36
0x23fe38 0x23fe38 0x23fe3a
cout<<++sptr;
cout<<" "<<sptr++<<" "<<sptr<<endl;
Why is it happening?