next up previous
Next: Example 2 Up: Overview of C++ Previous: Example 1:Convert the Gallons

Newline

Notice the difference between prog1 and prog2 (example 2). Prog2 in the last output statement has the following:

cout << "Liters =" << liters << "$\backslash$ n";

where << "$\backslash$ n" is used to generate new line. To put a newline character into a string, use "$\backslash$ n". In addition to using the newline character to advance the cursor, you can use the
\begin{emph}
endl \end{emph}
symbol in the identical way.



 

Yousef Haik
2/23/1998