I am trying to understand this code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
//---------------------------------------------------------------------------
#include <clx.h>
#include <iostream.h>
#include <conio.h>
#pragma hdrstop
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv)
{
cout << endl << "Starting program...." << endl << endl;
int i = 6;
while (i-- > 0)
{
cout << endl << "Today I have " << i;
cout << " problems to worry about.";
}
cout << "\b!\nYipee!";
cout << endl << endl << "Press any key to continue..";
getch();
return 0;
}
|
It is code in a book I am reading. I noticed the output on one of the last lines changes.
"Today I have 1 problems to worry about."
Then the next one shows this.
"Today I have 0 problems to worry about!"
From another post on this forum I see that /b is a back space.
So from that I concluded that
will backspace one time, replace the '.' with a '!' and display "Yipee!" on the next line.
So is the /n the same as endl?
That is the way I see it, can someone confirm?
If so, I should also be able to do the same with the line by nesting another loop to check if the i = 1 so it will not display 'problems.' and replace it with 'problem.'
-BHill