Home > Back-end >  , o root results different books, look at the results,
, o root results different books, look at the results,

Time:09-20

#include
# define SQ (y) (y) * (y))
Int main ()
{
Int I=1;
While (I & lt;
=5)Printf (" % d \ n ", SQ (i++));
return 0;
}

CodePudding user response:

Specifically for the process, the best theory are derived

CodePudding user response:

Don't use macros, use function,

CodePudding user response:

I'm dizzy

CodePudding user response:

And the fifth way that the study back word writing...

CodePudding user response:

I didn't understand what the fifth writing

CodePudding user response:

reference 5 floor mm2581883 reply:
I didn't understand what the fifth written


Kong yiji,,,

CodePudding user response:

You use this macro, at the time of each reference macro, i++ were performed twice...

Really want to use the macro, don't in the macro i++ similar this kind of way, can be changed to
 # include 
# define SQ (y) (y) * (y))
Int main ()
{
Int I=1;
While (I & lt;
=5){
Printf (" % d \ n ", SQ (I));
i++;
}
return 0;
}

CodePudding user response:

This is a bad programming habits, do not use # define macros

CodePudding user response:

To minimize the use of macros, is not to say that he is not convenient, just he is prone to errors such as # define PLUS (a) ((a) + (a)) and then call it with a PLUS (+) no namespace, easy to conflict (such as MAX often conflict, MIN) in the pretreatment stage was dealt with, difficult to repair after a compiler error, constexpr, typedef/using, inline, enum can replace most of the macro,

CodePudding user response:

SQ (i++) when the macro expansion ((i++) * (i++)), so do a SQ (i++), i++ twice, I value is 1,3,5 respectively.

CodePudding user response:

Tavern, 9/f,
reference ronin response:
minimize the use of macros, is not to say that he is not convenient, just he is prone to errors such as # define PLUS (a) ((a) + (a)) and then call when use PLUS (+) no namespace, easy to conflict (such as MAX often conflict, MIN) in the pretreatment stage was dealt with, difficult to repair after a compiler error, constexpr, typedef/using, inline, enum can replace most of the macro,

See your lists several ways to replace the define, learning typedef now, would you please tell me more?