Home > Back-end >  The small white would like to ask a question about C language pointer, a great god can help me with
The small white would like to ask a question about C language pointer, a great god can help me with

Time:10-13


Struct
{
Xx, int y;
} ss []={{2, 0}, {1, 3}}, * p=ss;

Printf (" % d, % d ", (+ + p) - & gt; Y, + + p - & gt; Y);

//this section of the compiled result is 3, 1


Struct
{
Xx, int y;
} ss []={{2, 0}, {1, 3}}, * p=ss;

Printf (" % d, % d ", + + p - & gt; Y, (+ + p) - & gt; Y);

//why this is wrong, this is a piece of the compiled result is 4


CodePudding user response:

Undefined behavior results meaningless
Don't discuss the results
More important is to understand what is undefined behavior and avoid to write such a code

CodePudding user response:

Indeed,
Don't think x=+ + + + + + a; This code is very profound is gorgeous, feel can write can read very cow force,
Write this code even if conform to the rules, whether it is a silly force,

X=+ + + + + + a; and the code is also wrong, undefined behavior (in other words is the result can not be sure the statement),

You the printf is also in the same way, undefined behavior, be specific understanding, probably understand C/C + + first, what expression, and then understand the expression side effects, and then understand the order point, basic is like this
  • Related