-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_void.c
More file actions
30 lines (28 loc) · 824 Bytes
/
Copy pathmain_void.c
File metadata and controls
30 lines (28 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
* =========================================================
* Filename: main_void.c
* Description: int main(void) 与 int main()在c中的区别
*
* =========================================================
*/
#include <stdio.h>
// Program 1 (Compiles and runs fine in C, but not in C++)
void fun() { }
int main(void)
{
fun(10, "GfG", "GQ");
return 0;
}
/* // Program 2 (Fails in compilation in both C and C++)
* void fun(void) { }
* int main(void)
* {
* fun(10, "GfG", "GQ");
* return 0;
* }
*/
/* So the difference is, in C, int main() can be called with any
* number of arguments, but int main(void) can only be called without
* any argument. Although it doesn’t make any difference most of the
* times, using “int main(void)” is a recommended practice in C.
*/