easy c++ loop with pause but output is very weird! -


I'm just trying to write a program that is one of the numbers that overwrite each other on the same line as the console screen. Outputs series. Such as 10 9 7 7 etc.

I am using xcode and compiling it in xcode. And it outputs "10 121469 121468", what am I doing? Why does not this look?

  #include & lt; Iomanip & gt; # Include & lt; Iostream & gt; using namespace std; #ifdef __GNUC__ #include & lt; Unistd.h & gt; #elif Defined _WIN32 #include & lt; Cstdlib & gt; #endif int main () {cout & lt; & Lt; "Description: This program will show you how much change" & lt; & Lt; Endl; Cout & lt; & Lt; "You already have" & lt; & Lt; Will need to complete the transaction using; Endl; Cout & lt; & Lt; "Specified sect" & lt; & Lt; Andal & lt; & Lt; Endl; Cout & lt; & Lt; "CTRL = C to exit ... \ n"; (Int units = 10; units; 0; units-) {cout & lt; & Lt; Units & lt; & Lt; ''; Cout.flush (); #ifdef __GNUC__Sleep (1); // A second # alip defined _WIN32 _sleep (1000); // one thousand milliseconds # andif cout & lt; & Lt; '/' R '; // CR} return 0; } // main    

I do not know if this answers your answer, I Have seen that your CR is incorrect.

  cout & lt; & Lt; '/' R '; // cr   

is 2 letters (which is printed on your 12146 screen). The correct value should be

  cout & lt; & Lt; '\ R'; // CR    

Comments