< previous page page_108 next page >

Page 108
This statement produces the output
Results: 15 2 6
If you want even more spacing between items, use string constants containing blanks:
cout << "Results: " << i << "   " << j << "  " << k;
Here, the resulting output is
Results: 15    2    6
As another example, to produce this output:
 * * * * * * * * *
* * * * * * * * * *
 * * * * * * * * *
you would use these statements:
cout << " * * * * * * * * *" << endl << endl;
cout << "* * * * * * * * * *" << endl << endl;
cout << " * * * * * * * * *" << endl;
All of the blanks and asterisks are enclosed in double quotes, so they print literally as they are written in the program. The extra endl manipulators give you the blank lines between the rows of asterisks.
If you want blanks to be printed, you must enclose them in quotes. The statement
cout << '*' <<                                '*';
produces the output
**
Despite all of the blanks we included in the output statement, the asterisks print side by side because the blanks are not enclosed by quotes.

 
< previous page page_108 next page >