Dag-Erling Sm=C3=B8rgrav <des@[EMAIL PROTECTED]
> writes:
> Keith Thompson <kst-u@[EMAIL PROTECTED]
> writes:
>> You should use "%s\n" rather than "%s" if you want each string to
>> appear on a line by itself. Or you can use puts() rather than
>> printf(), but for a novice it might be easier to use printf() for
>> everything.
>
> Or just use printf() anyway, whether you are a novice or a veteran.
> What is the use of microoptimizing a debugging printf()?
Sure, that's fine too.
I have no objection to either
printf("%s\n", some_string);
or
puts(some_string);
I don't think of the latter as a microoptimization of the former, just
a different way of expressing it.
But I do prefer
putchar('x');
to
printf("%c", 'x');
I'm not sure I can articulate the reason.
> Fun fact: when compiling hosted applications, gcc recognizes situations
> such as this one, where printf() is equivalent to puts(), and replaces
> the printf() call with a puts() call.
Yup.
--=20
Keith Thompson (The_Other_Keith) <kst-u@[EMAIL PROTECTED]
>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
--
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
-- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line. Sorry.


|