fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. char *uppercase(char source[])
  6. {
  7. int i;
  8. size_t len = strlen(source);
  9. char *tmp;
  10. tmp = malloc(len+1);
  11. memcpy(tmp, source, len+1);
  12.  
  13. for(i=0; i<len; ++i){
  14. if (tmp[i]>= 'a' && tmp[i]<= 'z'){
  15. tmp[i]= tmp[i]-'a' +'A';
  16. }
  17. }
  18.  
  19. return tmp;
  20. }
  21.  
  22. int main(){
  23. char *str = uppercase("cold");
  24. printf("%s", str);
  25. free(str);
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 2424KB
stdin
Standard input is empty
stdout
COLD