C语言编程题,输入1个字符串,把其中的小写字母改为大写

来源:百度知道 编辑:UC知道 时间:2024/09/12 21:14:59
急,谢谢各位哥哥姐姐们了

#include <stdio.h>
void main()
{
char ch[5];
int i;
puts("enter a string ");
gets(ch);
for(i=0;i<4;i++)
ch[i]=ch[i]-32;
puts(ch);

}

很简单啊,自己写吧

#include <ctype.h>
#include <stdio.h>

int main()
{
char str[50];
printf("enter a string:");
scanf("%s",str);
int i = 0;
while(str[i]!='\0')
{
if(islower(str))
str[i]=toupper(str[i]);
i++;
}
printf("\n%s\n",str);
return 1;
}

#include<stdio.h>
#include<conio.h>

void main()
{
char str[50],i;
gets(str);
//scanf("%s",str);
for(i=0;str[i];i++)
if(str[i]>='a'&&str[i]<='z')
str[i]=str[i]-32;
puts(str);
getch();
}

小写ASII码减32就是大写,自己编吧!