main

Is this code valid under any C standard?

与世无争的帅哥 提交于 2019-11-28 14:11:33
问题 Does this code follow C standards (e.g. C89, C99, C10x)? void main(int a,int b, int c, int d,char *msg){ if(d==1){ printf("%s\n",msg); }else{ main(1,2,3,1,&"Hello Stackoverflow"); } } If not, why? 回答1: There's one error: &"Hello Stackoverflow" does not have type char* , so you shouldn't pass that to a function expecting that type. Apart from that, this program is allowed by the Standard as an implementation-specific extension, but a compiler has the freedom to decline it. The function called

android os network on main thread exception

你离开我真会死。 提交于 2019-11-28 14:08:00
i make this code in single application working, but if join with other application , show this dialog "android os network on main thread exception" package com.kelompok2.bissmilahpulsa; import java.util.ArrayList; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import android.net.Uri; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.RadioGroup; import android.widget.TextView; public

does c++ standard prohibit the void main() prototype?

十年热恋 提交于 2019-11-28 13:39:03
In section 3.6.1.2 of both C++ Standard 1998 and 2003 editions, An implementation shall not predefine the main function. This function shall not be overloaded. It shall have a return type of type int, but otherwise its type is implementation-defined. I am not a native English speaker.I do not sure what does"but otherwise" means.Whether it is to prohibit the other return type,or to give the right to C++ compiler writer? So what's the answer? The english you quote does prohibit declaring main to return void . It is allowing variation in the arguments that come in, but not in the return type.

Python 2.7 on Windows, “assert main_name not in sys.modules, main_name” for all multiprocessing examples

我怕爱的太早我们不能终老 提交于 2019-11-28 13:34:39
There is following simple code: from multiprocessing import Process, freeze_support def foo(): print 'hello' if __name__ == '__main__': freeze_support() p = Process(target=foo) p.start() It works good on Linux or Windows with Python 3.3, but fails on Windows with Python 2.7. Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\Python27\lib\multiprocessing\forking.py", line 346, in main prepare(preparation_data) File "c:\Python27\lib\multiprocessing\forking.py", line 454, in prepare assert main_name not in sys.modules, main_name AssertionError: thread Generally

Writing a function inside the main method - Java

北战南征 提交于 2019-11-28 13:33:20
Can you write a method inside the main method? For example I found this code: public class TestMax { public static void main(String[] args) { int i = 5; int j = 2; int k = max(i, j); System.out.println("The maximum between is " + k); } public static int max(int num1, int num2) { int result; if (num1 > num2) result = num1; else result = num2; return result; } } Can the method max be coded inside the main method? When Java 8 comes out, the Closure/Lambda functionality should make it so that you can define the max method in the main method. Until then, you'll only be able to define a method in

main() in C, C++, Java, C#

自闭症网瘾萝莉.ら 提交于 2019-11-28 12:27:46
Is main() (or Main()) in C, C++, Java or C#, a user-defined function or a built-in function? It's a user-defined function that is necessary for a program to execute. When you go to run your program in the compiled language, the main function is what is executed. For instance, in Java, if you have a function of the signature public static void main(String ... args) in a class then that class can be executed, as the JVM will execute the contents of that main method. Example in Java: public class Test { public static void main(String ... args) { System.out.println("Hello World"); } } ... javac

Java Applet runs without a main method?

和自甴很熟 提交于 2019-11-28 12:26:43
I was running a Java class that extends Applet implements Runnable and apparently the program can run, but there is no main method. I thought Java applications needs the main method as its entry point? Java Applets have an init method instead of main. It's: public void init() {... } Donal Fellows Yes, but applets aren't applications. There is a main method in the applet runner (assuming it's implemented in Java; it need not be) but the applet doesn't work that way; it gets loaded/instantiated from a file and then it proceeds along its lifecycle through initialization , starting , operating,

main() function defined without return type gives warning

偶尔善良 提交于 2019-11-28 12:06:02
问题 This is my program: main() { printf("hello world\n"); } I get this warning when compiling it: function should return a value When changing main() to void main() , the warning disappears. Why is that so? 回答1: There are few things which you should take note of : The int is the main() function's return type. That means that the kind of value main() can return is an integer. main( ) was tolerated by the C90 compilers but not by C99 compilers which means its not a part of C99 standard anymore , so

What is the difference between wmain and main?

风格不统一 提交于 2019-11-28 10:44:36
So I have some class starting with #include <wchar.h> #include <stdlib.h> and there is a wmain function . How is it different from main function i usually use in my C/C++ programs? "If your code adheres to the Unicode programming model, you can use the wide-character version of main, which is wmain." http://msdn.microsoft.com/en-us/library/aa299386%28VS.60%29.aspx main( int argc, char *argv[ ], char *envp[ ] ) { program-statements } wmain( int argc, wchar_t *argv[ ], wchar_t *envp[ ] ) { program-statements } The difference between main and wmain is the type used to represent the arguments to

Maven Error: Could not find or load main class

和自甴很熟 提交于 2019-11-28 09:38:40
I'm using a Java Maven program and I don't know what to enter as the <mainClass> . I've tried all kinds of things based off of numerous stackoverflow questions , but they are not solving the error. Each time it says: Maven Error: Could not find or load main class ... I have this written inside my pom.xml (minus the ??? ) <build> ... <plugins> ... <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.5.3</version> <configuration> <descriptors> <descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor> </descriptors> <archive> <manifest> <mainClass> ??? </mainClass> <