cout vs printf execution sequence
-
#include #include void main() { cout<<"cout is executed"<
-
#include #include void main() { cout<<"cout is executed"<
This is most probably a result of buffering of the output streams. I would bet that depending on the scenario/platform/compiler you could get different results with this very same code. Don't write such code or flush the streams if you want to guarantee write order.
-
#include #include void main() { cout<<"cout is executed"<
Why are you trying to use both functions at once ? Is there any advantage ?
"If A is a success in life, then A=x+y+z. (Work is x; y is play; and z is keeping your mouth shut.)"
-
#include #include void main() { cout<<"cout is executed"<
If you're using a standard C++ compiler then the cout should happen first. However as you're not using a standard compiler (cout and printf are members of the std namespace for a standard compiler) then all bets are off. Get a new compiler and see if you have the same problem.
-
#include #include void main() { cout<<"cout is executed"<
What if you called "flush" at the end of each? Does it make a difference?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous