C语言出现这个提示是什么意思?

main()
{ int i=1,s=0;
while (i<=100)
{ s=s+1;
i++;
}
printf("s=%d\n",s);
}
提示我有两个错误:
[Error] C:\Users\lenovo\Documents\C-Free\Temp\未命名1.cpp:7: error: `printf' was not declared in this scope
[Warning] C:\Users\lenovo\Documents\C-Free\Temp\未命名1.cpp:8:2: warning: no newline at end of file

[Error] C:\Users\lenovo\Documents\C-Free\Temp\未命名1.cpp:7: error: `printf' was not declared in this scope的意思是 `printf'里的's'没有被定义

[Warning] C:\Users\lenovo\Documents\C-Free\Temp\未命名1.cpp:8:2: warning: no newline at end of file 是源文件的最后一行没有回车符造成的

“was not declared in this scope”是一个错误信息,在编译的时候会遇到。其含义为标识符在其出现的地方是未被定义的。

该错误出现时,需要根据出现该错误的行号及名称,查找对应名称变量或函数的作用,一般有如下几种可能:

1 忘记定义。写代码的时候疏忽了,导致一些变量直接使用但没有定义。只要对应定义相应的函数或变量即可。

2 拼写错误。写代码的时候,敲错了字符。比如sum敲成了Sum, average敲成averge等。对应修改即可。

3 作用域不正确。在超出变量和函数的作用域部分使用了该变量或函数。需要通过定义位置,或增加声明的手段,加大变量的作用域使其包含引用位置。

温馨提示:答案为网友推荐,仅供参考
相似回答