我是刚学VC的,看一些书上,在main()里头用return(1),有些用return(0),还有一些什么也不用的,请问它们三者有什么区别呢/

解决方案 »

  1.   

    main函数返回进程退出码,别的程序可以取得这个返回值,判断进程执行的结果。
      

  2.   

    main的返回值代表什么含义,系统没有定义,由你自己定义。一般来说,0表示成功完成任务,其他数值表示错误代码。
      

  3.   

    只是一个返回的数值而已,return(0),返回为0
    return(1),返回为1,同样你也可以是其他一个数值
    如2,3,4,5...
      

  4.   

    在main()里头,return应该是返回给操作系统的,如果按“ plane1980(fy) ”说的,返回某个非0数字给操作系统,将是什么意思呢?如果按“anyoshon(好学) ”说的,怎么定义这个返回给操作系统的值呢?
      

  5.   

    return [expression];The return keyword terminates execution of the function in which it appears and returns control (and the value of expression if given) to the calling function. A function returns an integer value by default. To define other types of return values, the name of the function is preceded by the type. If the function is type void, the return statement is omitted.ExampleIn the following example, a simple function with no parameters returns integer 0:// Examples of the return statement
    cypher()
       {
       return(0);
       }
    In the following example, a simple function with no parameters returns a double value:double fMultip()
       {
       double a;
       a = 4 * 3;
       return (a);
       }
    看不懂的话给我发短信!
      

  6.   

    main()的返回值是返回给操作系统的,如果你不在别的地方调用你的程序,那么return(1)和return(0)并没有什么区别。如果你在批处理或者别的程序里调用,那么main()的返回值可以用来确定你程序运行的状态和结果。