monoteen

1105_1_HW_1

Nov 4th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void MakeUpper(char *s);
  5.  
  6. int main(void)
  7. {
  8.     char str[] = "hello world";
  9.     MakeUpper(str);
  10.     printf("str = %s\n", str);
  11.    
  12.     return 0;
  13. }
  14.  
  15. void MakeUpper(char *s)
  16. {
  17.     int i;
  18.     int len = strlen(s);
  19.     int diff = 'a' - 'A';
  20.    
  21.     for(i=0; i<len; i++)
  22.     {
  23.         if(s[i] >= 'a' && s[i] <= 'z')
  24.             s[i] = s[i] - diff;
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment