Ask your own question, for FREE!
Computer Science 23 Online
OpenStudy (anonymous):

Which way is better, http://ideone.com/w44WC or http://ideone.com/8EJEC ? Do I use three consecutive for-loops, or should I use a single for-loop to do the same thing, or should I do something else?

OpenStudy (shadowfiend):

They're both fine. You can probably get clever with a single nested for and some solid use of the mod (%) operator.

OpenStudy (anonymous):

You repeated a lot of code there. Remove the repetition like this: #define PUTCHARS(ch,times) while (times-- > 0) putchar(ch) Then you can just call PUTCHARS('x', 80);

OpenStudy (anonymous):

I should note though, you're not 'calling' anything. Just creating a macro for replacement

OpenStudy (anonymous):

Is it better to define macros to do some procedure, or to define functions instead?

OpenStudy (shadowfiend):

Tough question. Sometimes the compiler will inline procedures for you, which makes for the same thing as defining a macro. But not always. It's an efficiency tradeoff, as these things often are in C/C++.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!