Quote:
|
Originally Posted by Dazlingo
a switch case ???
lol
just do smth lice c-'a' , where char c="current char"
of course u could use tolower to set them all to lower characters
|
yep this is the correct thinking :P, here ya go:
Code:
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
void main(void)
{
FILE * fp = fopen("text.txt","r");
FILE * outFile = fopen("textout.txt","w");
//the deal is character 'a' starts at index
//97 in the ascii set and z is 122
//so we just do character - 97
//this wont support characters that are not in the range of
//a-z or A-Z
char c = fgetc(fp);
while(c != EOF)
{
c = tolower(c);
c -= 97;
fprintf(outFile,"%i",c);
c = fgetc(fp);
}
fclose(fp);
fclose(outFile);
}