This is a discussion on What is the differnce between..... within the C and C++ forums, part of the Programming Talk category; What's the difference between main() / void main() / int main() / int main(void) / int main(int argc, char *argv[])...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Quote:
int main ( void ) int main ( int argc, char *argv[] ) Slight variations of the above are acceptable, where int can be replaced by a typedef name defined as int, or the type of argv can be written as char ** argv, and so on. The first option is used when you do not require access to the command line arguments. The names argc and argv are identifiers that can be changed if you so desire, but sticking to argc/argv is convention. The return type of main() must always be an int, this allows a return code to be passed to the invoker. for more ... Cprogramming.com: FAQ |
|
|||
|
I was reading at news groups... seems to be it's not clear,....
The first option is used when you do not require access to the command line arguments. The return type of main() must always be an int, this allows a return code to be passed to the invoker. |
|
|||
|
answer by usha
when you write
1) main(), means it is a main() function using standard C syntax. 2) void main() means you are using ANSI C/C++ syntax.This function is not returning any data type i.e. nothing 3)int main() means you are using ANSI C/C++ syntax.This function is returning integer data type 4) int main(void) means you are using ANSI C/C++ syntax.This function is returning int data type and you are not passing any actual parameter. 5) int main(int argc, char *argv[]) means you are using ANSI C/C++ syntax.This function is returning int data type and you are passing parameters as a command line argument first parameter i.e.argc will store number of arguments whose data type is integer and second parameter will store actual arguments their data types are pointer to characters. |
![]() |
| Thread Tools | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What is differnce between EAC, WAC, LIN, or SRC. | vegabonf | Immigration Help | 1 | 10-05-2004 08:06 PM |