如何设置C控制台窗口标题
如何在C中设置控制台窗口标题?
printf("%c]0;%s%c", '\033', "My Console Title", '\007');
这只适用于linux,不适用于windows。
有人知道“跨平台”解决方案吗? (当然不是 system ( title=blah )
)
How to set the console window title in C?
printf("%c]0;%s%c", '\033', "My Console Title", '\007');
This works only under linux, not in windows.
Does anybody know a "cross-platform" solution? (of course not system ( title=blah )
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
windows.h
定义SetConsoleTitle()
。您可以在任何地方使用它,并为 Linux 平台声明您自己的函数来执行相同的操作。
windows.h
definesSetConsoleTitle()
.You could use that everywhere, and declare your own function for linux platforms that does the same thing.
听起来类似于这个帖子:(这是针对 Java 的,但接受的答案使用 JNI [即 C Native 调用]。
如何从命令行 Java 应用程序更改命令提示符(控制台)窗口标题?
Sounds similar to this posting: (Which is for Java, but the accepted answer uses JNI [ie a C Native call].
How to change command prompt (console) window title from command line Java app?
您可以通过调用 SetConsoleTitle 来执行此操作。
You can do this by calling SetConsoleTitle.
也许您必须自己实施“跨游戏形式”解决方案。
对于 Windows 2000+,您可以使用 SetConsoleTitle(),更多信息可以在 MSDN。
Maybe you have to implement a "cross-playform" solution yourself.
For windows 2000+, you can use SetConsoleTitle(), more imformation can be found on MSDN.
在 C 中实现此目的的最简单方法是使用 windows.h 标头并使用 SetConsoleTitle 函数
简单脚本
The most easy way to achieve this in C is to use windows.h header and use the SetConsoleTitle function
Simple Script