Below is my c++ program to multiply two strings (Integers in strings) and produce the integer result in string. I believe it is due to cout flush problem. Can someone explai
You should notice that std::endl
includes flushing the output stream. As from the reference documentation:
Inserts a newline character into the output sequence
os
and flushes it as if by callingos.put(os.widen('\n'))
followed byos.flush()
.
So if you flush cout
after printing in your example
cout << multiply("0", "0");
cout.put(cout.widen('\n'));
cout.flush();
you would see the result printed Live Demo.
For more information about flushing and what it actually means for buffered output read here please std::ostream::flush().