Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 167 lines (148 sloc) 2.59 KB
/*
* 1337 speak program.
* Takes file named 'English' and outputs '1337', which
* should be a fairly direct translation.
*
* Dan Jackson, 9/01
*/
#define kWordMax 20
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
void ReadFile( FILE *f1337, FILE *fEnglish );
void WriteWord( char word[ kWordMax ], FILE *fEnglish);
void main(void)
{
FILE *fEnglish, *f1337;
if ( ( fEnglish = fopen( "English.txt", "r")) == NULL)
{
printf( "File 'English.txt' does not exist.\n" );
exit(1);
}
if ( ( f1337 = fopen( "1337.txt", "w")) == NULL)
{
printf( "Was unable to create '1337.txt'.\n");
exit(1);
}
printf("Woo!\n");
ReadFile( f1337, fEnglish );
fclose( f1337 );
fclose( fEnglish );
}
void ReadFile( FILE *f1337, FILE *fEnglish )
{
char word[ kWordMax ];
int more, i;
more = 1;
while(more)
{
for( i = 0; i< kWordMax; i++ )
{
word[i] = 0;
}
if( fscanf( fEnglish, "%[^ ] ", word) == EOF )
{
more = 0;
}
else
{
WriteWord( word, f1337 );
}
}
}
void WriteWord( char word[ kWordMax], FILE *f1337 )
{
int i;
// Look up special word and return if wanted.
i = 0;
while( word[i] != 0 )
{
switch( toupper( word[i] ) )
{
case 'A':
fprintf( f1337, "4");
break;
case 'B':
fprintf( f1337, "|3");
break;
case 'C':
fprintf( f1337, "(");
break;
case 'D':
fprintf( f1337, "|)");
break;
case 'E':
fprintf( f1337, "3");
break;
case 'F':
fprintf( f1337, "|=");
break;
case 'G':
fprintf( f1337, "9");
break;
case 'H':
fprintf( f1337, "|-|");
break;
case 'I':
fprintf( f1337, "|");
break;
case 'J':
fprintf( f1337, "j");
break;
case 'K':
fprintf( f1337, "|<");
break;
case 'L':
fprintf( f1337, "1");
break;
case 'M':
fprintf( f1337, "|\\/|");
break;
case 'N':
fprintf( f1337, "|\\|");
break;
case 'O':
fprintf( f1337, "0");
break;
case 'P':
fprintf( f1337, "|>");
break;
case 'Q':
fprintf( f1337, "q");
break;
case 'R':
fprintf( f1337, "|2");
break;
case 'S':
fprintf( f1337, "5");
break;
case 'T':
fprintf( f1337, "7");
break;
case 'U':
fprintf( f1337, "|_|");
break;
case 'V':
fprintf( f1337, "\\/");
break;
case 'W':
fprintf( f1337, "\\/\\/");
break;
case 'X':
fprintf( f1337, "><");
break;
case 'Y':
fprintf( f1337, "y");
break;
case 'Z':
fprintf( f1337, "2");
break;
default:
fprintf( f1337, "%c", word[i]);
break;
}
i++;
}
fprintf( f1337, " ");
}