警告:函数“system”的隐式声明

Noo*_*dle 0 c c++

我的编译器出错

警告:函数“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",&nothing);
system("cls");
printf("hello");
getchar();

return 0;
}
Run Code Online (Sandbox Code Playgroud)

这只是一个测试代码,所以很草率。我是编码新手,所以任何帮助将不胜感激。

duo*_*gja 8

对于 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