Which one do you prefer?
Bear in mind there's a right and a wrong choice here.
Which one do you prefer?
Other urls found in this thread:
kernel.org
twitter.com
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()
This one, user
int main(int argc, char *argv[argc+1])
>using square brackets in C
>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
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
>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
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
int main(int argc, char **argv, char **env)