C++: 'cout << pointer << ++pointer' generates a compiler warning

后端 未结 3 1900
迷失自我
迷失自我 2021-01-18 02:37

I have a C++ learning demo here:

char c = \'M\';
short s = 10;
long l = 1002;
char * cptr = &c;
short * sptr = &s;
long * lptr = &l;
cout <&         


        
3条回答
  •  时光取名叫无心
    2021-01-18 03:25

    You re having undefined behavior in lines 18, 19, 20. Cause of the result of executing the line will be different depending on whether ptr or ++ptr is evaluated first.

提交回复
热议问题