求助C语言大小写转换的
#include<stdio.h>void main()
{
char ch;
printf("\ninput a letter:");
scanf("%c",&ch);
if ch >= 'A' && ch <= 'Z'
{
ch = ch + 32;
}
else if ch >= 'a' && ch <= 'z'
{
ch = ch;
}
else
{
ch = 0
}
printf("%c\n",ch);
}
编译的时候显示有ERORR麻烦大神指导下格式错在哪里了,好人一生平安。 Compiling...
if.c
D:\C\if\if.c(7) : error C2061: syntax error : identifier 'ch'
D:\C\if\if.c(11) : error C2059: syntax error : 'else'
D:\C\if\if.c(15) : error C2059: syntax error : 'else'
D:\C\if\if.c(19) : error C2143: syntax error : missing ')' before 'string'
D:\C\if\if.c(19) : error C2143: syntax error : missing '{' before 'string'
D:\C\if\if.c(19) : error C2059: syntax error : '<Unknown>'
D:\C\if\if.c(19) : error C2059: syntax error : ')'
D:\C\if\if.c(20) : error C2059: syntax error : '}'
执行 cl.exe 时出错.
if.exe - 1 error(s), 0 warning(s)
这是报错提示 if ch >= 'A' && ch <= 'Z'
大哥呐,if后面要加括号的,把条件括起来的{:10_245:}
if(ch >= 'A' && ch <= 'Z') 感谢!
页:
[1]