警告:函数“系统"的隐式声明 [英] warning: implicit declaration of function 'system'

查看:88
本文介绍了警告:函数“系统"的隐式声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的编译器出现错误

警告:函数系统"的隐式声明

warning: implicit declaration of function 'system'

我添加了

system("cls");

能够清除屏幕,现在我得到了错误.我正在使用此代码进行测试

to be able to clear the screen, and now i get the error. I am using this code to test

#include <stdio.h>

int nothing; //random name

int main()
{
printf("this is a msg");
scanf("%d",&nothing);
system("cls");
printf("hello");
getchar();

return 0;
}

这只是一个测试代码,因此非常草率.我是编码的新手,所以将不胜感激.

This is just a test code, so its very sloppy. I am new to coding so any help would be appreciated.

推荐答案

对于C ++: #include< cstdlib> ,对于C语言: #include< stdlib.h> .

For C++: #include <cstdlib>, for C: #include <stdlib.h>.

或者,您可以执行以下操作:

Or, you can do as follows:

#ifdef __cplusplus__
  #include <cstdlib>
#else
  #include <stdlib.h>
#endif

if (system("CLS")) system("clear");

您还可以看到全文清除屏幕.

这篇关于警告:函数“系统"的隐式声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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