Mike Szer Mike Szer - 1 year ago 100
C++ Question

Time complexity of C++ cout?

What is the time complexity of making a

cout <<
in C++?

If I have a
in a loop, for example:

for(int i = 0; i < 1000000 ;i++){
std::cout << i << endl;

Without the
std::cout << i << endl;
would it be much faster the loop?

Answer Source

Time complextiy of Cout<<:

It completely depends on what type you are printing, how you overload your "operator<<", what operations you are doing inside "operator<< overloaded function.

ostream& operator<<(ostream& os, const "yourType"& T)

second question: Yes. Obviously. "Jon Trauntvein" provided good info on it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download