为什么这个程序编译的时候会报错?

来源:百度知道 编辑:UC知道 时间:2024/06/23 06:53:03
#include "stdio.h"
#include "stdlib.h"
void print()
{
printf("\n\t This is an example.\n\n\t You are welcome!!\n\n");
}
main()
{
int flag=1;
char ch;
while(flag)
{
printf("\n Input 'F'or'f' to start the program print,\n other to exit:");

ch=getchar();
ch=toupper(ch);
getchar();

if(ch=='F')
print();
else
flag=0;
}
return;
}

编译的时候会报:
WARNING C206 IN LINE 17 OF LI1.C: 'toupper': missing function-prototype
ERROR C267 IN LINE 17 OF LI1.C: 'toupper': requires ANSI-style prototype

如果把“ch=toupper(ch);”改为“ch=toupper();”
能编译成功,但报有两个“warning”--
C51 COMPILATION COMPLETE. 1 WARNING(S), 0 ERROR(S)
WARNING C206 IN LINE 17 OF LI1.C: '

#include <ctype.h>

#include <string.h>
可能需要这个头文件

这两个函数不是静态函数,需要对象来调用的。得这样
String aString="abc";
aString.ToUpper();
顺便说一声,大小写别打错了(我这个不一定对,详细看智能提示吧)

没有问题啊,我刚刚运行拉一下,没有任何问题你再试试