Listing 2: dcdr.c
/* program dcdr.c */
#include <stdio.h>
#include <ctype.h>
main()
{
char ch;
int offset;
do {
ch = getchar();
if (ch <= 79 && ch >= 33) {
offset = 79 - ch + 1;
ch = 79 + offset;
} /* end then */
else {
if (ch >= 80 && ch <= 126) {
offset = ch - 80 + 1;
ch = 80 - offset;
} /* end then */
} /* end else */
if (isupper(ch))
ch = tolower(ch);
else {
if (islower(ch))
ch = toupper(ch);
} /* end else */
if (ch != 0xff)
putchar(ch);
} while (!feof(stdin));
} /* end main */
/* end program dcdr.c */
|