如何重置程序 [英] how reset the program

查看:163
本文介绍了如何重置程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。

我想重置我的程序。例如,如果我按下键R我的程序从开始开始

我该怎么办?

Hi.
I want reset my program. for example if I press key R my program start from begin
how can I do that ?

推荐答案





对于控制台应用程序:

在代码文件的顶部,添加:

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.


这篇关于如何重置程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆