2012-09-15 42 views
-3

如何使用toupper函数转换字符串?这没有奏效。字符串不能将小写字母转换为大写字母作为c程序

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

int main(){ 
    char ch[20]; 
    printf("\nEnter Your String :"); 
    gets(ch); 

    int i=0; 
    for(i=0;ch[i] !='\0';i++) 
    { 
     putchar(toupper(ch[i])); 
     putchar(ch[i]); 
    } 

    return 0; 
} 

这个程序输出大写和小写我只是想大写output.i着抓住我的逻辑fault.please帮助我获得清晰的逻辑概念

+4

它不起作用?你期望什么产出,你会得到什么? –

+0

什么不起作用?你会得到什么输入和输出? – Myforwik

+3

您的程序[按编码工作:]](http://ideone.com/OB1wi)。 – dasblinkenlight

回答

0

我认为这将工作

for(i=0;ch[i] !='\0';i++) 
{ 
    ch[i]=toupper(ch[i]); 
} 

//print the string with uppercase 
+0

你的工作,感谢你。 –

相关问题