简体   繁体   English

在Mac OS X上清除屏幕

[英]Clear screen on mac Os X

I am using c++ on Qt creator. 我在Qt Creator上使用c ++。 I look for a command to clean screen. 我正在寻找清理屏幕的命令。

I tried system("CLS") and system("clear") but it did not work 我尝试了system("CLS") and system("clear")但是没有用

I try 我尝试

 #include <curses.h>
    clear();
    refresh(); 

I got this error: 我收到此错误:

Undefined symbols for architecture x86_64:
  "_clear", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

[From the source page:] The Curses library is designed for working with the console. [从源页面:] Curses库旨在用于控制台。 Advantages: it is cross-platform. 优点:它是跨平台的。 Disadvantages: it doesn't interact well with the standard streams. 缺点:它不能与标准流很好地交互。 In other words, you shouldn't mix printf() and the like or cout and the like with Curses. 换句话说,您不应将printf()之类的东西或cout之类的东西与Curses混合使用。 Use Standard I/O or Curses, but not both. 使用标准I / O或Curses,但不能两者都使用。 (You can still employ Standard I/O with things other than the terminal, of course.) (当然,您仍然可以将标准I / O用于终端以外的其他设备。)

#include <curses.h>

.
.
clear();
refresh(); // changes will appear on the screen after you call refresh()

You should get the NCurses distribution from here 您应该从这里获得NCurses发行版

To use the curses library, you need to link your project with it. 要使用curses库,您需要将项目与其链接。 In the project file (.pro), add the following line:[@KubaOber] 在项目文件(.pro)中,添加以下行:[@ KubaOber]

LIBS += -lcurses

Source 资源

The concept of a "screen" only applies if you're doing a console application. “屏幕”的概念仅在您正在执行控制台应用程序时适用。

To use the curses library, you need to link your project with it. 要使用curses库,您需要将项目与其链接。 In the project file ( .pro ), add the following line: 在项目文件( .pro )中,添加以下行:

LIBS += -lcurses

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM