1
0
Fork 0

actually use macros

This commit is contained in:
dtb 2022-10-16 18:43:27 -04:00
parent e1805936ef
commit 74e69d6c56
1 changed files with 11 additions and 8 deletions

View File

@ -47,8 +47,6 @@ static char alpha_upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM";
static char alpha_lower[] = "abcdefghijklmnopqrstuvwxyzabcdefghijklm";
int main(int argc, char *argv[]){
char *a; /* easier than doing freaky math */
CHARACTER c;
if(argc > 1){
fprintf(stderr, "Usage: %s\n",
@ -57,12 +55,17 @@ int main(int argc, char *argv[]){
return EX_USAGE;
}
while((c = getc(stdin)) != EOF)
if(isalpha(c)){
a = isupper(c) ? alpha_upper : alpha_lower;
putc(a[c - a[0] + 13], stdout);
}else
putc(c, stdout);
{ /* rot13 */
char *a; /* easier than doing freaky math */
CHARACTER c;
while((c = GETC(stdin)) != ENDOFFILE)
if(isalpha(c)){
a = isupper(c) ? alpha_upper : alpha_lower;
PUTC(a[c - a[0] + 13], stdout);
}else
PUTC(c, stdout);
}
return EX_OK;
}