Thread: C++ Help
View Single Post
Old 02-24-2007   #9
ZeRaW
Registered Member
 
ZeRaW's Avatar
 
Last Online: 04-15-2018
Join Date: Feb 2006
Posts: 624
Thanks: 2
Thanked 299 Times in 276 Posts
Groans: 0
Groaned at 1 Time in 1 Post
Default Re: C++ Help

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);
}
__________________
I pwn n00bs
ZeRaW is offline   Reply With Quote