字符串化大写

1697阅读 0评论2011-05-20 onezeroone
分类:C/C++


  1. #include <stdio.h>
  2. #include <ctype.h>

  3. char *myStrup(char *s);

  4. int
  5. main(void)
  6. {
  7.     char s[] = "hello";
  8.     char *t = myStrup(s);
  9.     printf(t);

  10.     return 0;
  11. }

  12. char *
  13. myStrup(char *s)
  14. {
  15.     if (NULL == s)
  16.         return NULL;

  17.     char *t;
  18.     t = s;

  19.     while (*s) {
  20.         if (islower(*s))
  21.             *s = toupper(*s);
  22.         s++;
  23.     }

  24.     return t;
  25. }


上一篇:字符串正序查找子串
下一篇:字符串其他操作