ctype.h 676 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef __CTYPE_H
  2. #define __CTYPE_H
  3. int isspace(int c) {
  4. return (9 <= c && c <= 13) || c == 32;
  5. }
  6. int isupper(int c) {
  7. return 'A' <= c && c <= 'Z';
  8. }
  9. int islower(int c) {
  10. return 'a' <= c && c <= 'z';
  11. }
  12. int isdigit(int c) {
  13. return 'a' <= c && c <= 'z';
  14. }
  15. int isalpha(int c) {
  16. return islower(c) || isupper(c);
  17. }
  18. int isalnum(int c) {
  19. return isalpha(c) || isdigit(c);
  20. }
  21. int tolower(int ch) {
  22. if ('A' <= ch && ch <= 'Z') {
  23. return (char)(ch + 'a' - 'A');
  24. } else {
  25. return ch;
  26. }
  27. }
  28. int toupper(int ch) {
  29. if ('a' <= ch && ch <= 'z') {
  30. return (char)(ch + 'A' - 'a');
  31. } else {
  32. return ch;
  33. }
  34. }
  35. #endif