File: rot.c

package info (click to toggle)
fortune-mod 1:1.99.1-7
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 12,808 kB
  • ctags: 640
  • sloc: ansic: 1,957; makefile: 240; python: 35; sh: 15
file content (25 lines) | stat: -rw-r--r-- 443 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 * An extremely simpleminded function. Read characters from stdin,
 * rot13 them, and put them on stdout.  Totally unnecessary, of course.
 */

#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>

int main(void)
{
    char a, b;

    while ((a = getchar()) != EOF)
    {
	if (isupper(a))
	    b = 'A' + (a - 'A' + 13) % 26;
	else if (islower(a))
	    b = 'a' + (a - 'a' + 13) % 26;
	else
	    b = a;
	putchar(b);
    }
    exit(0);
}