C++ 警告:函数的隐式声明';系统&x27;
我的编译器有一个错误 警告:函数“system”的隐式声明 我补充说C++ 警告:函数的隐式声明';系统&x27;,c++,c,C++,C,我的编译器有一个错误 警告:函数“system”的隐式声明 我补充说 system("cls"); 为了能够清除屏幕,现在我得到了错误。我正在使用此代码进行测试 #include <stdio.h> int nothing; //random name int main() { printf("this is a msg"); scanf("%d",¬hing); system("cls"); printf("hello"); getchar(); return
system("cls");
为了能够清除屏幕,现在我得到了错误。我正在使用此代码进行测试
#include <stdio.h>
int nothing; //random name
int main()
{
printf("this is a msg");
scanf("%d",¬hing);
system("cls");
printf("hello");
getchar();
return 0;
}
#包括
无整数//随机名称
int main()
{
printf(“这是一条消息”);
scanf(“%d”,无)(&T);
系统(“cls”);
printf(“你好”);
getchar();
返回0;
}
这只是一个测试代码,所以非常草率。对于C++,我是一名新手,希望您能给予我帮助。对于C++:\include
,对于C:\include
或者,您可以执行以下操作:
#ifdef __cplusplus__
#include <cstdlib>
#else
#include <stdlib.h>
#endif
if (system("CLS")) system("clear");
\ifdef\uuucplusplus__
#包括
#否则
#包括
#恩迪夫
if(系统(“CLS”)系统(“清除”);
您还可以看到一篇完整的文章w.r.t.当函数在声明之前被调用时,会报告此警告。在您的情况下,代码开头没有包含库stdlib.h。因此,编译器会在其原型之前看到对函数的调用。您应该在问题上标记“或”,而不是同时标记“或”。至于错误,这是因为
system
是在stdlib.h
中定义的。所以,包括这些。你能添加一些有价值的链接,使你的答案更好吗?!?