Convert string to upper case and lower case : String Case « String « C / ANSI-C





Convert string to upper case and lower case

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

int main(void)
{

  char str[80];
  int i;

  printf("Enter a string: ");
  gets(str);

  for( i = 0; str[ i ]; i++)
    str[ i ] = toupper( str[ i ] );

  printf("%s\n", str); /* uppercase string */

  for(i = 0; str[ i ]; i++)
    str[i] = tolower(str[ i ]);

  printf("%s\n", str); /* lowercase string */

  return 0;
}


           
       










Related examples in the same category

1.Change string case using its pointerChange string case using its pointer