我的编译器出错
警告:函数“system”的隐式声明
我补充说
system("cls");
Run Code Online (Sandbox Code Playgroud)
能够清除屏幕,现在我收到错误。我正在使用此代码进行测试
#include <stdio.h>
int nothing; //random name
int main()
{
printf("this is a msg");
scanf("%d",¬hing);
system("cls");
printf("hello");
getchar();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这只是一个测试代码,所以很草率。我是编码新手,所以任何帮助将不胜感激。
对于 C++: #include <cstdlib>,对于 C: #include <stdlib.h>。
或者,您可以执行以下操作:
#ifdef __cplusplus__
#include <cstdlib>
#else
#include <stdlib.h>
#endif
if (system("CLS")) system("clear");
Run Code Online (Sandbox Code Playgroud)
你也可以看到一篇完整的文章wrt Clear the screen。