Declaring main function
Hi,
I was looking at some of my old code that runs under MS-DOS 6. I noticed that the beginning of my programs looked like this:
/* Begin hello.cpp */
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[])
{
cout << "Hello World!\n";
system("PAUSE");
return 0;
}
The above code reminds me of Java's "public static void main( String args[] )"
I have some programs that use "void main()" instead of "int main(int argc, char *argv[])". I don't know where I learned to put int "argc, char *argv[]" inside the main function.
I never pass parameters to the main function. Has anybody seen something like this before? Is one method of declaring a main function better than the other? Or, when would I need to use "int main(int argc, char *argv[])" ?
Edit:</B Clarified first sentence. Thanks to everyone who replied! I gotta go now.
I was looking at some of my old code that runs under MS-DOS 6. I noticed that the beginning of my programs looked like this:
/* Begin hello.cpp */
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(int argc, char *argv[])
{
cout << "Hello World!\n";
system("PAUSE");
return 0;
}
The above code reminds me of Java's "public static void main( String args[] )"
I have some programs that use "void main()" instead of "int main(int argc, char *argv[])". I don't know where I learned to put int "argc, char *argv[]" inside the main function.
I never pass parameters to the main function. Has anybody seen something like this before? Is one method of declaring a main function better than the other? Or, when would I need to use "int main(int argc, char *argv[])" ?
Edit:</B Clarified first sentence. Thanks to everyone who replied! I gotta go now.
