
- Forum
- Programming Talk
- C and C++
- What is the differnce between.....
What is the differnce between.....
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[])...
-
What is the differnce between.....
What's the difference between main() / void main() / int main() / int main(void) / int main(int argc, char *argv[])
-
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
-
11-06-2006, 08:09 AM #3
- Join Date
- Oct 2005
- Answers
- 1
I think, According to me
int main()
and
int main(void) has no difference. Both are same.
-
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.
-
void main() means returning the main() with void datatype.
int main() means returning the main() with int datatype.
int main(void) means returning the main() with int datatype and no argumernts.
-
11-28-2006, 01:58 AM #6
- Join Date
- Nov 2006
- Answers
- 2
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.
-
Sponsored Ads

Reply With Quote






