Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++

Name: Anonymous 2008-02-02 12:11

Hi /prog/

return 0; or not? \n or endl?

#include <iostream>
using namespace std;
int main()
{
    cout << "Hello World!" << endl;
    return 0;
}

#include <iostream>
using namespace std;
int main()
{
    cout << "Hello World!\n";
}

Name: Anonymous 2008-02-03 0:32

The function will return at the end irregardless of whether a return statement is present. So unless you plan to be using the return value for something, it's unnecessary.

\n saves a few extra characters when it's the last thing to be output in a string, but otherwise endl is easier to type.

cout << "my other car is a cdr.\n"
vs
cout << "number of scientologists killed: " << victims << endl;

BUT IT DOESN'T MATTER, YOU SHOULD BE USING printf()

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List