353
unsafeCode (lemmy.ml)
you are viewing a single comment's thread
view the rest of the comments
[-] lily33@lemm.ee 37 points 1 week ago* (last edited 1 week ago)

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

[-] Bogus5553@lemm.ee 30 points 1 week ago* (last edited 1 week ago)

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

[-] stebo02@lemmy.dbzer0.com 7 points 1 week ago

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

[-] barubary@infosec.exchange 9 points 1 week ago

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

[-] stebo02@lemmy.dbzer0.com 2 points 1 week ago

yeah I thought so, does it work in C?

[-] Bogus5553@lemm.ee 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.

load more comments (2 replies)
load more comments (4 replies)
load more comments (4 replies)
this post was submitted on 11 Feb 2025
353 points (100.0% liked)

Programmer Humor

33584 readers
33 users here now

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

Rules:

founded 5 years ago
MODERATORS