Advertisement
AedenCak3

Changing all character of a STRING to lowercase using built-in function

Dec 16th, 2021
862
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<ctype.h>
  3. #include<string.h>
  4. void changeCase(char s[]);
  5.  
  6. int main()
  7. {
  8.     char a[100];
  9.     printf("Enter a string:");
  10.     gets(a);
  11.     changeCase(a);
  12.     puts(a);
  13.  
  14.  
  15. }
  16.  
  17. void changeCase(char str[])
  18. {
  19.  
  20.     int i;
  21.     for(i=0; str[i]!='\0'; i++)
  22.     {
  23.         if (isupper(str[i]))
  24.         {
  25.             str[i]=tolower(str[i]);
  26.         }
  27.         else if (islower(str[i]))
  28.         {
  29.             str[i]=tolower(str[i]);
  30.         }
  31.     }
  32.  
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement