Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- #include "checkit.h"
- int rot_13(unsigned char i)
- {
- if ((i >= 'A' && i <= 'M') || (i >= 'a' && i <= 'm'))
- {
- i = i + 13;
- }
- else if ((i >= 'N' && i <= 'Z') || (i >= 'n' && i <= 'z'))
- {
- i = i - 13;
- }
- else if (i == '\n')
- {
- printf("Invalid input.\n");
- }
- return i;
- }
- void test_cases(void)
- {
- /* checkit_string(rot_13("abcd"), "nopq");
- checkit_string(rot_13("hello", uryyb);
- checkit_string(rot_13("Clarence", Pynerapr);*/
- }
- int user_interaction()
- {
- unsigned char i;
- printf("Please enter a character string.\n");
- i = 50;
- i = getchar();
- while (i != EOF)
- {
- printf("%c", rot_13(i));
- i = getchar();
- }
- return 0;
- }
- int main(void)
- {
- test_cases();
- user_interaction();
- return 0;
- }
Add Comment
Please, Sign In to add comment