Guest User

Untitled

a guest
Jun 18th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4. #include "checkit.h"
  5.  
  6. int rot_13(unsigned char i)
  7. {
  8.    if ((i >= 'A' && i <= 'M') || (i >= 'a' && i <= 'm'))
  9.    {
  10.       i = i + 13;
  11.    }
  12.    else if ((i >= 'N' && i <= 'Z') || (i >= 'n' && i <= 'z'))
  13.    {
  14.       i = i - 13;
  15.    }
  16.    else if (i == '\n')
  17.    {
  18.       printf("Invalid input.\n");
  19.    }
  20.  
  21.    return i;
  22. }
  23.  
  24. void test_cases(void)
  25. {
  26.  
  27.  /*  checkit_string(rot_13("abcd"), "nopq");
  28.    checkit_string(rot_13("hello", uryyb);
  29.    checkit_string(rot_13("Clarence", Pynerapr);*/
  30. }
  31.  
  32. int user_interaction()
  33. {
  34.    unsigned char i;
  35.  
  36.    printf("Please enter a character string.\n");
  37.    i = 50;
  38.  
  39.    i = getchar();
  40.    while (i != EOF)
  41.    {
  42.       printf("%c", rot_13(i));
  43.       i = getchar();
  44.    }
  45.  
  46.    return 0;
  47. }
  48.  
  49. int main(void)
  50. {
  51.    test_cases();
  52.    user_interaction();
  53.  
  54.    return 0;
  55. }
Add Comment
Please, Sign In to add comment