this post was submitted on 11 Feb 2025
350 points (95.6% liked)

Programmer Humor

32710 readers
407 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 39 points 1 week ago* (last edited 1 week ago) (1 children)

That is why I use just int main(){...} without arguments instead.

[–] [email protected] 28 points 1 week ago* (last edited 1 week ago) (3 children)

Any void main(){...} enjoyers?

[–] [email protected] 7 points 1 week ago (2 children)

besides not requiring a return value, what difference does it make?

[–] [email protected] 9 points 1 week ago (1 children)

@stebo02 @Bogus5553 Neither of them require a return value, but void main isn't legal C++.

[–] [email protected] 2 points 1 week ago (1 children)

yeah I thought so, does it work in C?

[–] [email protected] 4 points 1 week ago* (last edited 1 week ago)

void main(){...} is not in the standard, but works on both MSVC and GCC (with warnings). I think it works on both C/C++, but you really shouldn’t use it in production. Just use int main(void){...} , without any return value, which is permitted in the standard, and will return success iirc.

[–] Buddahriffic 2 points 1 week ago

It will also give an error if you try to add a return value anyways.

[–] [email protected] 2 points 1 week ago

while (true) {...}

[–] [email protected] 1 points 1 week ago

int main(void) { . . . } for me!