converting file to Rot13

I making a program that suppose to read a file that was given by user and translates it to rot13. I tested the program it reads the file but it does not convert it to rot13. How can I fix the while loop.

1
2
3
4
5
6
7
8
9
10
11
12
13
  	char rot13;
	while(inFile){            
	inFile.get(rot13);
	
		if(rot13>='A'&&rot13<='M') 
			rot13+=13;
		if(rot13>='a'&&rot13<='m') 
			rot13+=13; 
		if (rot13>='N'&&rot13<='Z') 
			rot13-=13; 
		if(rot13>='n'&&rot13<='z') 
			rot13-=13;
			
Last edited on
that looks correct. what exactly does it not do?

It doesn't translate to rot13. it just prints what is in the file.
the problem isnt the code you posted. your bug is something else in your program, like printing the original file instead of the new output.

add
cout << rot13 <<;
after all the if statements above.

is that output translated correctly?

Last edited on
I added the cout<<rot13 and found that the loop works. So it looks like i'm printing the old file instead of new file.
Last edited on
instead of cout << rot13 you need
outfile << rot13 I think, then open and check the output file in a text editor.
Topic archived. No new replies allowed.