good simple rot13 code needed please

Discuss PocketC for CE (including Desktop Edition)

Postby Johnny on Sat Mar 15, 2003 1:23 am

here is a c sample
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int main(void) {
char c, offset;
while ((c = getchar()) != EOF) {
if (isalpha(c)) {
offset = isupper(c) ? 'A' : 'a';
putchar(offset + ((c - offset + 13) % 26));
} else {
putchar(c);
}
}
return EXIT_SUCCESS;
}
Johnny
 
Posts: 2
Joined: Sat Feb 08, 2003 3:31 am

Return to PocketC for CE

Who is online

Users browsing this forum: No registered users and 5 guests

cron