|
Why do we need to use int main and not void main in c++?
Started by kasperasky on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
As you probably know, the return value from the main() function is used....
A long answer can be found at void main() is not legal in C++ but is legal in C .
The short answer, is because the C++ standard requires main() to return int .
|
|
Possible Duplicate:
What does <if __name__==”__main__”:> do?
I occasionally notice something like the following in Python scripts:
if __name__ == "__main__": # do stuff like call main()
What's the point of this?
Started by BipedalShark on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Without file directly, the __name__ variable will....
The sole purpose of this, assuming it is in main.py , is so other files can import main to include classes and functions that are in your "main" program, but without running the source code.
|
|
Why the function name main() is retained in many languages like C, C++, Java? Why not any other names for that function? Is there any common structure for all these 3 main() (in C, C++, Java)
Started by Nethra on
, 19 posts
by 18 people.
Answer Snippets (Read the full thread at stackoverflow):
And lets not forgot that PL/1 used "procedure options main!)
Probably because it's the main....
The language designers had to choose "some" name and main() sounds like the Main function, since more Java experience than Gosling.
|
Ask your Facebook Friends
|
I am using Eclipse. I deleted everything and left the main function - nothing is working. Can somebody pls help?
package good; import java.io.*; public class FiFo { public static void main() { System.out.println("here"); } } class FileReader { public ...
Started by Shaz on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
The main function should have a signature like:
public static void main( String[] args ) { // stuff:
Exception in thread "main" java.lang.NoSuchMethodError: main
The Java VM requires that the class you execute with it have ....
|
|
I'm porting an existing (mostly) cross-platform application to WinCE 4.2. The current entry point for the function is
int main(int argc, char *argv[]){}
I would like to keep this part as-is, and have the WinCE entry point simply call it. I believe something...
Started by drhorrible on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Args.push_back(NULL); int result; try { //....
Argc = main(argc,&argv); delete argv; // You are returning the result of main.
The arguments passed to your main function would be something like this:
argc = 7; argv is not valid here.
|
|
Does it matter which way I declare my C++ programs?
Started by Lucas McCoy on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
Void main(....
Int main(int argc, char** argv)
or
int main()
is the proper definition of your main per the C++ spec.
And, Yes it does matter.
The difference is one is the correct way to define main, and the other is not.
|
|
The form that currently loads during when our beta WinForm application starts up is one that shows a vast array of buttons... "Inventory", "Customers", "Reports", etc. Nothing too exciting.
I usually begin UI by looking at similar software products to...
Started by proudgeekdad on
, 10 posts
by 10 people.
Answer Snippets (Read the full thread at stackoverflow):
Among the options are:
A “dashboard” main form, showing summarized.
Accomplish their tasks.
|
|
Hi Servlet is also java program but there is no main method in servlet.Who will take role of main method on servet.
Answer Snippets (Read the full thread at stackoverflow):
Servlet 'main' in your servlet (the whole thing is not started from servlet), which is inside application server (you could imagine the startup of application....
GenericServlet.service() is roughly analagous to main() in a plain old java class.
|
|
Is it possible to get the path to my .class file containing my main function from within main?
Started by Hamza Yerlikaya on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
URL main = Main.class.getResource("Main.class"); if (!"file".equalsIgnoreCase....
However, I suggest reading http://stackoverflow.com/questions/41894/0-program-name-in-java-discover-main-class , which at least gives you the main class .
|
|
What way is the most efficient and why? int main()? void main()? return 1? return 0?
Started by Joel on
, 12 posts
by 12 people.
Answer Snippets (Read the full thread at stackoverflow):
Abnormal termination is usually signalled by a non-zero return but there is no standard for how non-zero... .
Normal exit is generally represented by a 0 return value from main.
The return value for main should indicate how the program exited.
|