this is a very common poll, however, i must say i always use both, but i like more printf, BUT cin is MUCH better than scanf. scanf really ........es me off. but i really like printf!...
cout
printf()
Either
Neither
this is a very common poll, however, i must say i always use both, but i like more printf, BUT cin is MUCH better than scanf. scanf really ........es me off. but i really like printf!...
You are correct. I recall Sunlight getting quite upset on the subject... Not that it was an unusual state for him or anything. ... RANT: system(), cout, goto, DOS... you name it.I think printf() is faster. I vaguely (very very very vaguely) remembered a discusion on the old board. and I think it was Sunlight who wrote a program to test it and printf() was faster.
Printf is faster than cout by a fair margin. I dont use either now though as i've only created DirectX Apps lately.
"There's always another way"
-lightatdawn (lightatdawn.cprogramming.com)
>>sprintf() Might be the same, I never used it
sprintf just copies on string over another...I wouldn't say it's faster thanprintf() because it does something totally different
Yeah, I :VERY: vaguely recall that...I use printf() when I do C/C+ DOS/Console stuff, anyhow so I didn't really care. I learned printf() first...ah, how I miss those late nights enthralled in C For Dummies .
But I'm with lightatdawn. I haven't DONE console stuff in a long time...the only time I ever use it is if I'm testing out an algorithm that I'm putting in a larger windows app. But then again lately I've been C#-ing and creating my own OS (so I use my own write() function, now )
What is the difference between printf(), sprintf() and putch()?
-----------------
Engineer223
Yoshi
Even though I started learning C with printf(), i've gotten more comfortable with cout << for some reason.
The book that I started C++ with used cout << so I have never used anything else. also, when I look at code which uses other thins, it looks all weird and hard to read/understand.
printf, since you have v/s/printf and you can reroute a variable argument list... which means you can do formatted output with a different output...
hasafraggin shizigishin oppashigger...
printf...
I'm more comfortable with the formatted printing of printf.
And, no, C++ is not fully backwards compatible with C. When C++ branched of with OOP, C kept moving forward. I could give an example if you like.
--Garfield
1978 Silver Anniversary Corvette
printf() is much better because you have to think more when you use it. You must always know what data type you have. This can prevent errors. You can also do something like this with printf():
the output is the ASCII-code for 'a'. You cannot do it with cout.Code:char c='a'; printf("%d",c);
klausi
When I close my eyes nobody can see me...
You can explicitely cast the char to a double like so;printf() is much better because you have to think more when you use it. You must always know what data type you have. This can prevent errors. You can also do something like this with printf():
code:--------------------------------------------------------------------------------
char c='a';
printf("%d",c);
--------------------------------------------------------------------------------
the output is the ASCII-code for 'a'. You cannot do it with cout.
cout << (double)c << endl;
As far as I know that's what printf is doing anyway
But cout << isnīt compatible to C !
You can use your C++ compiler to program C-compatible code.
But if you only know senseless functions like cout << thatīs very difficult!
klausi
When I close my eyes nobody can see me...
>>But cout << isnīt compatible to C !
Hmm....I cant remember saying it was
>sprintf just copies on string over another...
it does formatted output to a string... i would say that is faster considering that outputting to the console is a slow job [because of the hardware updates]... whereas if it's just formatted output in memory, it's quick as can be... so i'd say that maybe sprintf is faster than printf... [don't confuse sprintf with being just a wrapper over printf because of the name... redirecting output has variations on speed depending on the media output...]
hasafraggin shizigishin oppashigger...
According to my compiler and profiler, cout is on average 5.75 milliseconds faster than printf. So much for that argument...
That's becuase printf is formatted printing. Note the formatting aspect. Time. Just means that you would have to do the formatting somewhere else in you C++ code.
--Garfield
1978 Silver Anniversary Corvette