Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5.  
  6. int *toUpper(char *str){
  7.     if (str) {
  8.        if (str[0] != '\0'){     // check the first element
  9.             int i;
  10.             for (i = 0; i < strlen(str); i++) {
  11.             if (str[i] >= 'a' && str[i] <= 'z') {
  12.             str[i] = str[i] - 'a' + 'A';
  13.                 }
  14.             }
  15.        }
  16.        return str;
  17.      }
  18.      else{ // else
  19.             printf("rossz");
  20.      return NULL;      //indicate error condition
  21.      }
  22.  }
  23.  
  24. int main(int argc, char **argv)
  25. {
  26.      for (int i = 1; i < argc; ++i)
  27.     {
  28.         printf(toUpper(argv[i]));
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement