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-02 21:56

>>8
no, no it doesn't.


#define y(a, b) ((a)+(b)) /* adds a and b */
#define x y

x(1, 2); /* error */

Name: Anonymous 2008-02-02 22:22

>>9
Define them in reverse order and it works. The C preprocessor is a filthy hack.

Name: Anonymous 2008-02-02 22:34

>>10
No, it's not a filthy hack, please don't repeat things you've heard on IRC channels or blogs. It's *you* who does not know C (nor how the preprocessor treats tokens)

god dammit faggots, nobody knows C here?

Name: Anonymous 2008-02-02 22:45

C is a dead language.

Name: Anonymous 2008-02-02 22:52

ITT: IOStreamfags

Use stdio, faggots

Name: Anonymous 2008-02-02 22:55

>>12
nemo me impune lacessit

Name: Anonymous 2008-02-02 23:04

>>14
/b/ritfag

Name: Anonymous 2008-02-02 23:07

>>15
no, not really
I remember it from poe's story, ``the cask of amontillado"

Name: Anonymous 2008-02-03 0:06

>>11
The point is that comparing CPP's #defines (which are crappy macros largely inferior to the macros in CL) to Scheme's (defines) (which are fucking FUNCTIONS) is absolutely retarded. >>8 is a complete moron who read the word "define" and assumed that it must be the same thing as C's macros.

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()

Name: Anonymous 2008-02-03 1:17

>>SHOULD BE USING printf()

/thread

also notice my lack of EXPERT QUOTES

Name: Anonymous 2008-02-03 1:18

[quote]also notice my lack of EXPERT QUOTES[/quote]

I did. Go and lern2BBCode

Name: Anonymous 2008-02-03 1:32

>>18
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.

It's not about whether or not it returns, it's what it returns. The real reason people leave it out is because the compiler will include it for you if it's omitted. No other function gets this special treatment.

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