#include #include #include //for the function chrono::milliseconds #include //for the function this_thread::sleep_for using namespace std; int main() { char a[70]; const size_t 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 = ' '; } //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; } cout << flush; //Flush the output buffer for smoother animation. //Sleep for 250 milliseconds (a quarter of a second). this_thread::sleep_for(chrono::milliseconds(250)); } cout << "\n"; //Go down one line. cout << "BOOM!\n"; return EXIT_SUCCESS; }