#include #include //#include //for class ostream_iterator //#include //for the fill and copy algorithms #include //for the function std::chrono::milliseconds #include //for the function std::this_thread::sleep_for using namespace std; int main() { char a[70]; int n {size(a)}; //the number of elements in the array //Fill up the array with spaces. for (char *p {a}; p < a+n; ++p) { *p = ' '; } //fill(begin(a), end(a), ' '); //Easier way to do the same thing. //During each iteration of this loop, the ++p makes us //redraw the rocket one character farther to the right. for (char *p {a}; p <= a+n-3; ++p) { p[0] = '.'; //trailing puff of smoke p[1] = '='; p[2] = '='; p[3] = '>'; //the nose cone cout << "\033[2J"; //Clear the screen. cout << "\033[H"; //Home the cursor. //Output the array onto the top line of the screen. for (char *q {a}; q < a + n; ++q) { cout << *q; } //Easier way to do the same thing: //copy(begin(a), end(a), ostream_iterator(cout)); cout << flush; //Flush the output buffer for smooth animation. //Sleep for 250 milliseconds (a quarter of a second). this_thread::sleep_for(chrono::milliseconds(250)); } cout << "\n"; //Go down one line. return EXIT_SUCCESS; }