1 year ago
#387731
Munir Mohamed
why cout statement in Ubuntu not working as expected?
I tried to write this code in Ubuntu and run it from terminal but the problem is the second "cout" statement prined before the first one.
for (int i = 5; i > 0; i--) {
cout << " the program will start within " << i << " seconds" << endl;
cout << " be ready";
sleep(1); //sleep 1 second before clearing the terminal
system("clear");
}
** the output:
be ready the program will start within 4 seconds **
I wrote the corresponding code in windows and it runs successfully
c++
ubuntu
terminal
command
cout
0 Answers
Your Answer