如何通过更正此错误来编译此代码?第二行有错误[错误]':: main'必须返回'int' [英] How can I compile this code by correcting this error? There is error in second line [error] '::main' must return 'int'
本文介绍了如何通过更正此错误来编译此代码?第二行有错误[错误]':: main'必须返回'int'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include<iostream.h>
void main()
{
char ch;
cout<<"Enter your NAME="<<ch;
cin>>ch;
getch();
}
我的尝试:
i尝试输入int而不是void但错误没有纠正
What I have tried:
i tried to type int instead of void but error didn't rectified
推荐答案
只需按照消息告诉你的内容。设main()
返回int
:
Just do what the message told you. Letmain()
return anint
:
int main()
{
// Other code goes here
return 0;
}
请注意,如果不使用相当的话,还应包括 iostream
(不含.h)旧的C ++编译器。
Note that you should also include iostream
(without .h) when not using a quite old C++ compiler.
这篇关于如何通过更正此错误来编译此代码?第二行有错误[错误]':: main'必须返回'int'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文