你如何从程序用C完成后,关闭保持控制台? [英] How do you keep the console from closing after the program is done in C?

查看:180
本文介绍了你如何从程序用C完成后,关闭保持控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/1173208/what-is-the-best-practice-for-combating-the-console-closing-issue\">What是打击控制台关闭问题的最佳实践?

你如何保持控制台从程序是用C完成后,关闭?当我试图寻找它,我觉得很多东西约C ++等语言,但没有为C.另外,即使是C ++似乎没有成为一个明确的答案。

How do you keep the console from closing after the program is done in C? When I try to search for it I find lots of stuff about C++ and other languages, but nothing for C. Also, even for C++ there doesn't seem to be a definitive answer.

所以可能有人请让我知道什么是C程序完成后,运行最简单的方式(不需要是超级优雅的)的方式来保持控制台打开?

So could someone please let me know what the simplest way (doesn't need to be super elegant) way to keep the console open after a C program is done running?

推荐答案

在previous答案都是假设你要调用的控制台应用程序,然后基本上是离开它跑,并等待用户输入终止。如果这是正确的假设,然后+1 GMAN的答案。但是,如果你是问如何从任一个快捷方式,开始 - >运行或一些其他机制调用此控制台应用程序,并留下cmd窗口打开,则需要通过 CMD.EXE <调用它/ code>本身像这样的 / K 选项:

The previous answers are all assuming that you want to invoke the console app and then essentially leave it "running" and waiting for user input to terminate. If this is the correct assumption, then +1 to GMan's answer. However, if you are asking how to invoke this console app from either a shortcut, Start->Run or some other mechanism and leave the cmd window open, then you will need to invoke it via cmd.exe itself with the /k option like so:

cmd.exe /k "foo.exe"

这将启动一个cmd窗口,运行控制台应用程序,然后离开cmd窗口打开。这将上面的地址@Thanatos。他是正确的,你应该让控制台应用程序关闭。再次,对我来说这是不清楚你真正寻求的最终目标应该是什么。

This will start a cmd window, run your console app, and then leave the cmd window open. This will address @Thanatos above. He's correct in that you should let the console app close. Again, for me it's unclear what you're really asking for what the end goal should be.

如果我做出了错误的假设上,随时为-1我。

If I made the wrong assumption(s), feel free to -1 me.

这篇关于你如何从程序用C完成后,关闭保持控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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