编写程序,将用户输入的一串字符(以回车结束)中的小写字母改为大写字母。

编写程序,将用户输入的一串字符(以回车结束)中的小写字母改为大写字母。
比如:abef12W 输出 ABEF12W

#include <stdio.h>
#define N 50
void main(){
char s[N];
int i=0;
printf("输入字符串:\n");
scanf("%s",&s);
printf("转换前的字符串为:%s\n",s);
while(s[i]!='\0'){
if(s[i]>='a'&&s[i]<='z')
s[i]-=32;
i++;
}
printf("转换后的字符串为:%s\n",s);
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-06-23
#include <stdio.h>
#include <string.h>

int main()
{
char *str;
gets(str);
strupr(str);
puts(str);
return 0;
}

相关了解……

你可能感兴趣的内容

大家正在搜

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网