Hi, everybody.
I am reviewing some old code and two questions came to mind.
1) Is it better to use “\n” or endl?
"\n" seems to be working just fine, but most code samples I see in books nowadays use endl. What is the difference?
2) For multi-line output statements, is it better to avoid repeating the cout part of the statement?
For example, at the beginning of the program, some instructions are output to the user; a sample block follows:
cout << "\nThe first entry of this file must be the degree, N, of the polynomial for\n";
cout << "which the roots are to be calculated.\n";
cout << "Entries for the coefficients of the polynomial should follow, starting with\n";
cout << "the coefficient for the highest power of x and working down to the coefficient\n";
Is it better to write this block as follows (one big long single cout statement)?
cout << "\nThe first entry of this file must be the degree, N, of the polynomial for\n"
<< "which the roots are to be calculated.\n"
<< "Entries for the coefficients of the polynomial should follow, starting with\n"
<< "the coefficient for the highest power of x and working down to the coefficient\n";