fork download
  1. #include <stdio.h>
  2.  
  3. void upper_to_lower(char s[]) {
  4. int c = 0;
  5. int shouldConvert = 0;
  6. while (s[c] != '\0') {
  7. if (s[c] >= 'A' && s[c] <= 'Z') {
  8. if (shouldConvert) {
  9. s[c] += 'a'-'A';
  10. } else {
  11. shouldConvert = 1;
  12. }
  13. } else {
  14. shouldConvert = 0;
  15. }
  16. c++;
  17. }
  18. }
  19.  
  20. int main() {
  21. char text[100];
  22.  
  23. printf("Text\n");
  24. fgets(text, 99, stdin);
  25. upper_to_lower(text);
  26. printf("This is the text:\n%s", text);
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 2172KB
stdin
LEAF. IS? GREEN!
stdout
Text
This is the text:
Leaf. Is? Green!