I am trying to make a simple program in c++ that reads text from a txt file, decodes it using ROT13, then prints the decoded message to another txt file.
I am getting pretty lost and what I have now just loops infinitely.
#include<iostream>
#include<fstream>
#include<string>
usingnamespace std;
int main(){
ifstream inputstuff;
ofstream outputstuff;
inputstuff.open("secretMessage.txt");
outputstuff.open("decodedMessage.txt");
char c=0;
inputstuff.get(c);
while (!inputstuff.eof()){
if (c>='a' && c<='m') c += 13;
elseif (c >= 'n' && c <= 'z') c -= 13;
elseif (c >= 'A' && c <= 'M') c += 13;
elseif (c >= 'N' && c <= 'Z') c -= 13;
inputstuff.get(c);
cout<<c;
}
return 0;
}
I am just trying to use cout for now so I can see what is going on in a console. If any one could point me in the right direction I would be most grateful.
if(!(inputstuff >> foo))
{
if (inputstuff.eof())
{
cout << "read failed due to end of file\n";
}
else
{
cout << "read failed due to something other than end of file\n";
}
}