c语言中开头的int main (void)是什么意思。我真的知道int是整数void是0,但是我 c语言中的int main(void)是什么意思

c\u8bed\u8a00\u4e2d\u5f00\u5934\u7684int main \uff08void\uff09\u662f\u4ec0\u4e48\u610f\u601d\u3002\u6211\u771f\u7684\u77e5\u9053int\u662f\u6574\u6570void\u662f0\uff0c\u4f46\u662f\u6211

void \u4e0d\u662f0
main \u8fd4\u56de int \u73b0\u5728\u662f\u6807\u51c6\u8981\u6c42\u7684\uff0c\u8001\u7684\u7f16\u8bd1\u5668\u4e00\u822c\u90fd\u8fd0\u884c\u8fd4\u56de void\uff0c\u610f\u601d\u662f\u7a7a\u7684\uff0c\u5373\u6ca1\u6709\u8fd4\u56de\u3002\u4f46\u662f main \u8fd4\u56de\u503c\u662f\u7528\u6765\u8fd4\u56de\u7ed9\u7cfb\u7edf\u7684\uff0cshell \u53ef\u4ee5\u4f7f\u7528\u5176\u8fd4\u56de\u503c\uff0c\u6240\u4ee5\u5b9e\u9645\u4e0a\u603b\u4f1a\u8fd4\u56de\u4e00\u4e2a\u6574\u6570\uff0c\u901a\u5e38\u7528\u8fd4\u56de0\u8868\u793a\u7a0b\u5e8f\u6b63\u5e38\u7ed3\u675f\u3002
\u4e00\u822cmain\u7684\u5e38\u7528\u5f62\u5f0f\u662f\uff1a int main( int argc, char **argv)
\u8fd8\u53ef\u4ee5\u8fdb\u4e00\u6b65\u4f20\u9012\u73af\u5883\u53d8\u91cf

\u8fd9\u662fC\u8bed\u8a00main\u51fd\u6570\u7684\u4e00\u79cd\u58f0\u660e\u65b9\u5f0f\uff0c\u8be5\u65b9\u5f0f\u8868\u660e\u8fd9\u4e2amain\u51fd\u6570\u4e0d\u5e26\u53c2\u6570\uff0c\u8fd4\u56de\u503c\u3002
void\u5e38\u7528\u5728\u7a0b\u5e8f\u7f16\u5199\u4e2d\u5bf9\u5b9a\u4e49\u51fd\u6570\u7684\u53c2\u6570\u7c7b\u578b\u3001\u8fd4\u56de\u503c\u3001\u51fd\u6570\u4e2d\u6307\u9488\u7c7b\u578b\u8fdb\u884c\u58f0\u660e\u3002
int main(void)\u8fd8\u53ef\u4ee5\u5199\u4e3a void main\uff08\uff09\u6216\u8005 int main\uff08\uff09\u6700\u540e\u5728mian()\u51fd\u6570\u7ed3\u675f\u65f6\uff0c\u5199return 0\u5373\u53ef\u3002

\u6269\u5c55\u8d44\u6599\uff1a
void\u771f\u6b63\u53d1\u6325\u7684\u4f5c\u7528\u5728\u4e8e\uff1a
1\uff0c\u5bf9\u51fd\u6570\u8fd4\u56de\u7684\u9650\u5b9a\u3002
2\uff0c\u5bf9\u51fd\u6570\u53c2\u6570\u7684\u9650\u5b9a\u3002
\u5728Java/C/C++/C#\u4e2d\uff0cmain\u4e3a\u7a0b\u5e8f\u8fd0\u884c\u7684\u4e3b\u5165\u53e3\u65b9\u6cd5\uff0c\u6bcf\u4e2a\u7a0b\u5e8f\u53ea\u6709\u4e00\u4e2a\u3002main \u4f5c\u4e3a\u51fd\u6570\u53ef\u4ee5\u6ca1\u6709\u53c2\u6570main\uff08void\uff09\uff0c\u4e5f\u53ef\u4ee5\u6709\u53c2\u6570\u3002
C\u8bed\u8a00\u4e00\u5b9a\u9700\u8981main\u51fd\u6570\uff1a
\u4efb\u4f55\u4e00\u4e2aC++\u7a0b\u5e8f\u90fd\u5305\u542b\u4e00\u4e2amain\u51fd\u6570\uff0c\u8fd9\u662f\u89c4\u5b9a\u3002main\u51fd\u6570\u7531\u7cfb\u7edf\u76f4\u63a5\u8c03\u7528\uff0c\u662f\u7a0b\u5e8f\u6267\u884c\u7684\u5165\u53e3\u3002
main\u51fd\u6570\u4e0e\u7528\u6237\u81ea\u5df1\u5b9a\u4e49\u7684\u51fd\u6570\u90fd\u662f\u5404\u81ea\u72ec\u7acb\u7684\u6a21\u5757\uff0c\u5373\u51fd\u6570\u4e0d\u80fd\u5d4c\u5957\u5b9a\u4e49\uff0c\u901a\u4fd7\u7684\u8bf4\uff0c\u4f60\u4e0d\u80fd\u5728\u4e00\u4e2a\u51fd\u6570\u7684\u51fd\u6570\u4f53\u5185\u5b9a\u4e49\u53e6\u4e00\u4e2a\u51fd\u6570\uff0c\u5373\u4f7f\u5728main\u51fd\u6570\u4e2d\u4e5f\u4e0d\u884c\u3002\u4f46main\u51fd\u6570\u53ef\u4ee5\u5bf9\u7528\u6237\u81ea\u5df1\u5b9a\u4e49\u7684\u51fd\u6570\u8fdb\u884c\u8c03\u7528\uff08\u4f46main\u51fd\u6570\u53ea\u80fd\u7531\u7cfb\u7edf\u8c03\u7528\uff09\u3002
\u7528\u6237\u81ea\u5df1\u5b9a\u4e49\u591a\u4e2a\u51fd\u6570\u65f6\uff0c\u8fd9\u51e0\u4e2a\u7528\u6237\u81ea\u5df1\u5b9a\u4e49\u7684\u51fd\u6570\u4e4b\u95f4\u90fd\u53ef\u4ee5\u4e92\u76f8\u8c03\u7528 \u3002
\u53c2\u8003\u8d44\u6599\u6765\u6e90\uff1a\u767e\u5ea6\u767e\u79d1-main

int代表返回值,即函数返回一个int类型的值,void在这里代表,main函数的参数为空,而不是0的意思。main函数,为主函数,一个程序的入口函数,一般返回值为int类型,有时编译器做了优化,在编程是没有返回任何值也不会报错。不太正规的,返回值也可以用void代替,即返回值为空。

int是函数的类型,每一个函数都会有一个返回值,在这里标int就表示函数的返回值是int类型的
void是函数的形参,函数都要运算参数,可以为空的,void就表示此函数不用进行实参与形参的传递

int 是指这个主函数执行后会返回一个int类型的值 如 函数最后返回 return 1; void 不是0,它表示该函数不需要传参数。如 function person(int age){}这个函数执行时就会传一个int型的参数 如 调用时可以写成 person(20);

扩展阅读:int main开头为什么错了 ... int main在c中是什么意思 ... int main 括号里填什么 ... int a[10]={ }哪里错了 ... c语言int main 什么意思 ... int main void 含义 ... c语言printf用法例子 ... 编程int main什么意思 ... int main void 什么意思 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网