+ 2

Why do some people prefer printf/scanf over cin/cout in c++ ?

2nd Oct 2017, 9:44 AM
Ishan
Ishan - avatar
2 Respostas
+ 11
printf and scanf functions are C language legacy in C++. Comparing these two guys with cout and cin objects respectively, you will found out in the first place that former ones are a bit dumb (but faster) and you have to give the direction of what they are intended to do about their arguments. (e.g. printf("I have $%d in my pocket.", 20); VS. cout << "I have
quot; << 20 << " in my pocket.";) Overall, if you want a better performance in terms of I/O and can afford to deal with format characters then go for former ones, otherwise stick to your gun and use later ones.
2nd Oct 2017, 11:06 AM
Babak
Babak - avatar
+ 3
i think because sometimes u gotta print numbers with format specifiers...if u want a specific decimal point like 12.03(only two decimal places)
2nd Oct 2017, 10:00 AM
Suhail Pappu
Suhail Pappu - avatar