actually use macros
This commit is contained in:
parent
e1805936ef
commit
74e69d6c56
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user