如何使C控制台应用程序等待才退出?

发布于 2025-01-26 18:01:58 字数 78 浏览 1 评论 0原文

看来我找不到这个问题的任何解决方案,所以我问你。 C不支持iostream和console.ReadKey,除非我做错了什么,否则请提供帮助!

It seems that I can't find any solution to this problem, so I'm asking you. C doesn't support iostream and Console.Readkey unless i did something wrong, so please help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

千仐 2025-02-02 18:01:58

C

 getc(stdin);

c ++

std::cin.get();

最糟糕的示例在许多网站上列出

system("pause"); //never use this

请参阅system(“ pape”);

C

 getc(stdin);

C++

std::cin.get();

Worst Example Listed on Many Websites

system("pause"); //never use this

See what's wrong with system("pause");

↘紸啶 2025-02-02 18:01:58

您可以使用getchar()getc(stdin)读取字符。该控制台默认情况下是线条缓冲的(至少在Linux上),因此它意味着它将等待Enter

You can use getchar() or getc(stdin) to read a character. The console is line buffered by default (at least on Linux) so it means it will wait for enter.

简美 2025-02-02 18:01:58

在您的代码顶部导入此内容:

#include <windows.h>

然后您可以使用:

sleep()

在括号中,您可以写几秒钟的时间,您希望您的程序暂停!

希望这会有所帮助(尽管我迟到了三个月)

import this at the top of your code:

#include <windows.h>

then you can use:

sleep()

in the brackets you can write for how many seconds do you want your program to pause!

Hope this helps (although Im 3 months late)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文