Advertisement
Guest User

Vezba 16

a guest
Feb 9th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int duzina_stringa(char s[])
  4. {
  5. int i = 0;
  6. while (s[i] != '\0')
  7. {
  8. i++;
  9. }
  10. return i;
  11. }
  12.  
  13. char toUpperChar(char c)
  14. {
  15. if (c >= 'a' && c <= 'z')
  16. {
  17. c = c - 'a' + 'A';
  18. }
  19. return c;
  20. }
  21.  
  22. char toLowerChar(char c)
  23. {
  24. if (c >= 'A' && c <= 'Z')
  25. {
  26. c = c - 'A' + 'a';
  27. }
  28. return c;
  29. }
  30.  
  31. void toUpperString(char s[])
  32. {
  33. int i = 0;
  34. while (s[i] != '\0')
  35. {
  36. s[i] = toUpperChar(s[i]);
  37. i++;
  38. }
  39. }
  40.  
  41. void toLowerString(char s[])
  42. {
  43. int i = 0;
  44. while (s[i] != '\0')
  45. {
  46. s[i] = toLowerChar(s[i]);
  47. i++;
  48. }
  49. }
  50. int main()
  51. {
  52. char s[256];
  53.  
  54. while (1)
  55. {
  56. gets(s);
  57. printf("%d \n", duzina_stringa(s));
  58. toUpperString(s);
  59. puts(s);
  60. toLowerString(s);
  61. puts(s);
  62. if (duzina_stringa(s) == 0)
  63. break;
  64. }
  65.  
  66. return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement