Which one do you prefer?

Which one do you prefer?
Bear in mind there's a right and a wrong choice here.

Attached: argv.png (1200x1200, 33.04K)

Other urls found in this thread:

kernel.org/doc/html/v5.10/process/coding-style.html#indentation
twitter.com/NSFWRedditGif

What about int main(int argc, char** argv[])?

The second one is the right choice. Also, return 0 must be always specified (no matter what the standard says).

Obviously first.

int main()

Attached: 1647106233407.jpg (701x752, 81.9K)

This one, user

Attached: 1637678434197.jpg (1280x720, 113.72K)

int main(int argc, char *argv[argc+1])

>using square brackets in C

Attached: EW-fa5TU8AEh3Qk.jpg (851x851, 52.17K)

>extra line that changes nothing in the program
. the second one is indeed the right one, though, and SDL recommends using it

i like this

extern int
main(int argc, char *argv[])
{
|------>if (argc < 2) {
|------>|------>fprintf(stderr, "No arguments provided!\n");
|------>|------>return 1;
|------>}

|------>/* do regular stuff here */

|------>return 0;
}


|------> here represents a TAB character, 8 space wide ofc

[] is super weird in C, so I prefer **.

Do not threat main as a special function. It should return an int and the return statement must be explicit.
It's a matter of consistency and good practice.

actually indentation should be 4 spaces

Attached: 1639150054793.jpg (828x991, 155.46K)

Why not call exit in main then? It's consistent with termination in other functions.

>not 4 char tabs

void main(void)

INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, INT nCmdShow)

A function whose return value is int must (explicitly) return an int. Calling exit does not address this issue.

They arent even the same thing so of course there is a wrong choice.

kernel.org/doc/html/v5.10/process/coding-style.html#indentation
>Tabs are 8 characters, and thus indentations are also 8 characters. There are heretic movements that try to make indentations 4 (or even 2!) characters deep, and that is akin to trying to define the value of PI to be 3.
sorry chuds, i use the CORRECT indentation

>variable-length arrays

Attached: kots-straal.gif (220x343, 312.34K)

they're the same in C. you can't directly pass an array to a function in C, it decays down to a pointer.

>define the value of PI to be 3.
Yes
.t engineer

for me, it's
int main(void)

Second is “correct” but first is quicker to type + looks better and thus is the best option.

int main(int argc, char *argv[static argc+1])

cringe

wrong. pi is 7/22. source: calulator

Attached: 2022-04-02-130515_231x399_scrot.png (231x399, 6.22K)

int main(int argc, char **argv, char **env)