相关疑难解决方法(0)

在C++中递归到main()是否合法?

我读到C++标准禁止递归main(),但是g ++编译以下代码而没有抱怨:

int main()
{
    main();
}
Run Code Online (Sandbox Code Playgroud)

任何人都可以澄清这个吗?

c++ recursion standards program-entry-point

45
推荐指数
4
解决办法
3542
查看次数

为什么在C++中不允许调用main()

C++03 3.6.1.3:函数main不得在程序中使用(3.2)....

我想知道为什么这个规则存在...是否有人知道任何系统/实现,如果使用main,它将是一个问题?

PS 1.我知道该术语的定义used.2.我知道有一些简单的解决方法,比如从main()调用单个MyMain()并使用MyMain()代替.3.问题是关于现实世界的实施,如果不存在限制则会产生问题.谢谢!

c++ program-entry-point

16
推荐指数
3
解决办法
803
查看次数

main()函数在C++中调用自身,会发生什么?

#include <iostream>

int main()
{
    main();
    std::cout<<"Hello World! "<<std::endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

这是代码,它的表现如何?为什么?

c++ program-entry-point

1
推荐指数
1
解决办法
1348
查看次数

我不明白此错误(LPCWSTR)

嗨,我只在尝试启动C时为植物大战僵尸教练编写代码,但由于以下错误而失败:

错误:无法将参数'2'的'LPCWSTR {aka const wchar_t *}'转换为'LPCSTR {aka const char *}'到'HWND __ * FindWindowA(LPCSTR,LPCSTR)'|

这是我的代码:

#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
    system("color 0A");//change the colour of the text
    cout << "PlantsVsZombies Trainer voor game of the year edition(gemaakt door Pjotr Slooff)" << endl;//display some (dutch) text
    cout << "Open PlantsVsZombies en druk dan op enter" << endl;
    system("Pause");//wait for the user to press enter
    LPCWSTR Game = L"Plants vs. Zombies";
    HWND hwnd = FindWindowA(0, Game);
    if (hwnd …
Run Code Online (Sandbox Code Playgroud)

c++

0
推荐指数
1
解决办法
650
查看次数

标签 统计

c++ ×4

program-entry-point ×3

recursion ×1

standards ×1