// John Bent's CS 110 Hand-out 14 // Spinning line // // This program for a do-nothing for loop to output a // spinning line to the screen. // The loop consists of consecutive characters written on // top of each other: -, then \, then |, then /, back to - #include int main() { unsigned int LargeNumber = 555555; cout << endl << " - "; // start the loop spinning for (int j = 0; j < 200; j ++) { for (unsigned int i = 0; i < LargeNumber; i++) ; // busy wait if (j%4==0) { cout << "\b\b\\ "; cout.flush(); } // if1 else if (j%4==1) { cout << "\b\b| "; cout.flush(); } // if2 else if (j%4==2) { cout << "\b\b/ "; cout.flush(); } // if3 else { cout << "\b\b- "; cout.flush(); } // if4 } // for cout << "\b\b* done." << endl; // put a '*' over the spinning loop return 1; }