[英]Error C244 '{': missing function header (old-style formal list?) Visual C++
I've been looking at a lot of questions similar to mine but all of the answers are about how something is just wrong in the code. 我一直在看很多与我的问题类似的问题,但是所有答案都与代码中的某些错误有关。 So I've been looking in mine and I can't find anything wrong with it.
因此,我一直在寻找我的产品,但找不到任何错误。 Though I guess it makes sense since I'm just starting out with C++.
尽管我认为这很有意义,因为我只是从C ++开始。 Here is the code:
这是代码:
#include <windows.h>
#include <conio.h>
int Main = MessageBox(NULL, "Testing", "Testing", MB_YESNO);
{
if (Main == IDYES) {
MessageBox(NULL, "Testing2", "Testing", NULL)
break;
}
else if (Main == IDNO) {
MessageBox(NULL, "Testing3", "Testing", NULL)
break;
}
return 0;
}
Your program needs to define a function called main
. 您的程序需要定义一个称为
main
的函数。 The main
function is what gets called by the environment when your program starts running. main
功能是程序开始运行时环境所调用的功能。
( main
and Main
are distinct identifiers, but I suggest that using the name Main
for an object could be confusing.) (
main
和Main
是不同的标识符,但我建议对对象使用名称Main
可能会造成混淆。)
The definition of the main
function should look like this: main
功能的定义应如下所示:
int main() {
// code goes here
}
The #include
directives are fine where they are, but everything else should be inside the definition of main
. #include
指令可以在任何地方使用,但其他所有内容都应在main
的定义内。
More complex structures are possible (for example you can have file-scope declarations and multiple function definitions), but this should get you started. 可能会有更复杂的结构(例如,您可以具有文件作用域声明和多个函数定义),但这应该可以帮助您入门。
Your code should like something like this: 您的代码应如下所示:
#include <windows.h>
#include <conio.h>
int main(){
int result = MessageBox(NULL, "Testing", "Testing", MB_YESNO);
if (result == IDYES){
MessageBox(NULL, "Testing2", "Testing", NULL)
}
else if (result == IDNO){
MessageBox(NULL, "Testing3", "Testing", NULL)
}
return 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.