Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: Re: I don't use printf enough

by elusion (Curate)
on Oct 23, 2003 at 03:00 UTC ( #301465=note: print w/replies, xml ) Need Help??


in reply to Re: Re: I don't use printf enough
in thread I don't use printf enough

Presumably, he/she finds it ironic beacuse
cout << "text text " << obj.method1() << " more text " << end1;
is like using string concatenation in Perl. The root node says to use printf sometimes. printf is a C function, yet it would not be the preferred way of doing things in C.

So to prefer printf in Perl when something like the above (preferred) C snippet exists, is ironic.

Replies are listed 'Best First'.
Re: Re: Re: Re: I don't use printf enough
by bunnyman (Hermit) on Oct 23, 2003 at 15:25 UTC

    printf is a C function, yet it would not be the preferred way of doing things in C.

    That's half right - printf is a C function, but it is not preferred in C++. It is preferred in C, of course.

    The reason why printf is not the best way in C++ is that the compiler cannot check the variable types. If you use "%s" to print a string, and then use an integer variable instead, the program crashes at run time. With perl it would just convert the integer into a string and not crash, and with C++ style I/O, it would print the integer as a string. Also, printf cannot be extended to print objects, it is only able to print a few built in types.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://301465]
help
Chatterbox?
[Corion]: Sane Dots Supplies - your brand manufacturer for satisfying experiences!
[choroba]: preparing the trip to Vietnam + buying a new car = enough fun
[Corion]: choroba: Yeah, that's a lot of "fun" for one week...
[Corion]: I guess I should stage some product photos for Sane Dots Supplies ;)
[marto]: I had some ideas about that Corion
[marto]: I'll send a message over the weekend maybe :P
[Corion]: choroba: I avoided the "fun" of emergency shopping for a new flat iron by trying the flat iron without the timer that sat between it and the mains power. Seems as if just the timer is broken.
[Corion]: marto: Heh, would be cool!

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2017-01-20 10:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (174 votes). Check out past polls.