如何清除C中的屏幕? [英] How do I clear the screen in C?

查看:66
本文介绍了如何清除C中的屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想清除屏幕上的所有文本.我尝试使用:

I want to clear all the text that is on the screen. I have tried using:

#include <stdlib.h>
sys(clr);

提前谢谢!我正在使用OS X 10.6.8.抱歉造成混乱!

Thanks in advance! I'm using OS X 10.6.8. Sorry for the confusion!

推荐答案

清除屏幕的最佳方法是通过stdlib.h中的 system(const char * command)调用Shell:

The best way to clear the screen is to call the shell via system(const char *command) in stdlib.h:

system("clear"); //*nix

system("cls"); //windows

再说一次,尽量减少对调用系统/环境的函数的依赖总是一个好主意,因为它们会导致各种未定义的行为.

Then again, it's always a good idea to minimize your reliance on functions that call the system/environment, as they can cause all kinds of undefined behavior.

这篇关于如何清除C中的屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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