-3

How can I convert a string using the toupper function? This did not work.

#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;
}

this program output both upper and lowercase i just want to uppercase output.i cant catch my logic fault.please help me to get clear logic concept

MH Raihan
  • 31
  • 6

1 Answers1

0

I think This will work

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

//print the string with uppercase
Rajan
  • 255
  • 1
  • 5
  • 16