cout & cin are part of the iostream interface for input and output. They are an ostream object and an istream object, respectively. They use the overloaded << operator to output any object, based on its type and the various flags set by manipulators.
printf and scanf are part of the stdio.h interface also known as cstdio. They are variable-argument functions, which use a format specification to tell them what the types of their arguments are. Some find the iostream interface easier, and it is safer and expandable. However, these advantages come at a small performance penalty. printf and scanf on the other hand are a bit faster, but are unsafe, and some find them harder to use.
You didn't measure the startup time. Cin and cout have penalties for startup. In addition, you didn't measure for different types of operands. When outputting an entire object, say a spaceship, a single printf call like: printf("%s: %f %f %f %f %f %f %d",s.name,s.x,s.y,s.z,s.dx,s.dy,s.dz,s.fuel);
is about twice as fast as cout with 8 separate operator overload function calls: cout << s.name << s.x << s.y << s.z << s.dx << s.dy << s.dz << s.fuel;
I've run and posted extensive tests in another thread showing the overhead. If you like I will give you a link.
I'd love to see that, sure. :)
edit: Still, if you take the creating of the string outside the loop, with lets say std::stringstream and sprintf(), and output just the strings, cout will obviously still beat printf.
I tested what you pasted, and added spaces to the cout line, just to make it identical (even more function calls) and I didn't get 2:1 printf win, more or less 4.1:2.7 - printf still is faster, considerably.
In real world though, the object would probably provide its own printing function (or << overload) that should usually implement sort of caching of the string representation, if the object didn't change from one printing to another. (That is, if one object would be assumed to be printed this way a lot in its lifetime)
In that case cout would be faster if we would print the objects that are rarely ever modified, and a slkightly slower if we would print lots of barely-new/modified objects. It would depend on how often they would be printed and modified.
Bah, I hope I didn't start cout/printf flame all over again? In the end it's not really speed that counts, but plenty of other things too. :)
Actually, in this thread I conclusively proved that printf > iostream > istringstream. On this particular post I demonstrated that even with optimization, cout and cin are more than twice as slow as scanf and printf. http://www.cplusplus.com/forum/general/33845/page4.html#msg183520
As for istringstream, read the thread. It was started when someone noticed that istringstream is as slow as a turtle in molasses.