更新时间:2023-01-11 21:18:26
对于控制台应用程序:
在代码文件的顶部,添加:
Hi,
For a console application:
At the top of your code file, add this:
#include <conio.h>
在你的 main
方法:
In your main
method:
bool stop = false;
while (!stop)
{
system("cls"); // clear console
// run your program
int pressedChar = getch();
stop = pressedChar != 114; // 114 = 'R'
}
return 0;
对于Windows应用程序:
看看这里:
http://www.cplusplus.com/forum/windows/42674/ [ ^ ]
如何创建一个可自动重启的应用程序 [ ^ ]
希望这会有所帮助。
For a Windows application:
Have a look here:
http://www.cplusplus.com/forum/windows/42674/[^]
How To Create a Self-Restartable Application[^]
Hope this helps.
您需要向主类添加一个清除所有视图和文档的方法,并将所有控制变量重置为初始状态。但是,只有你知道那些是什么。
You need to add a method to your main class that purges all views and documents and resets all control variables to their initial state. However, only you know what those things are.