Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C Moderated > Re: Sorry, newb...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 12 Topic 1058 of 1145
Post > Topic >>

Re: Sorry, newbie question about generating a random string

by Keith Thompson <kst-u@[EMAIL PROTECTED] > Mar 30, 2008 at 02:58 PM

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.
 




 12 Posts in Topic:
Sorry, newbie question about generating a random string
Scooter <slbentley@[EM  2008-03-08 12:21:06 
Re: Sorry, newbie question about generating a random string
Keith Thompson <kst-u@  2008-03-17 15:19:13 
Re: Sorry, newbie question about generating a random string
=?utf-8?Q?Dag-Erling_Sm=C  2008-03-28 19:20:30 
Re: Sorry, newbie question about generating a random string
Keith Thompson <kst-u@  2008-03-30 14:58:21 
Re: Sorry, newbie question about generating a random string
Jack Klein <jackklein@  2008-03-17 15:19:52 
Re: Sorry, newbie question about generating a random string
Jonathan Leffler <jlef  2008-03-17 15:21:03 
Re: Sorry, newbie question about generating a random string
Barry Schwarz <schwarz  2008-03-17 15:21:22 
Re: Sorry, newbie question about generating a random string
Carl Barron <cbarron41  2008-03-17 15:21:31 
Re: Sorry, newbie question about generating a random string
Francis Glassborow <fr  2008-03-17 15:21:40 
Re: Sorry, newbie question about generating a random string
Kenneth Brody <kenbrod  2008-03-17 15:22:01 
Re: Sorry, newbie question about generating a random string
Vinicius Pinto <vinici  2008-03-17 15:22:07 
Re: Sorry, newbie question about generating a random string
David Thompson <dave.t  2008-03-28 19:20:14 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Sep 4 23:55:21 CDT 2008.