My professor in his grading robot decided to put a unicode character in a ciphering program and my code really doesnt like it at all. Can anyone help me without using loops?

//
//Caesars Cipher
//program encrypts a file using caesars cipher
//Due 9/9/11
//created 9/9/11
//last modified 9/9/11

#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main()
{
    //Define Variable
	char ch;
	//Open files
	ifstream infile;
	ofstream outfile;
	infile.open("program2.bat");
	outfile.open("message");
	//get character and convert
    cout << ch;
    infile >> ch;
    ch=(ch-3);
    //print chracter to screen
    cout << ch;
    //send char to message
    outfile<<ch;
    //repeat 11 times
    infile >> ch;
    ch=(ch-3);
    cout << ch;
    outfile<<ch;
    infile >> ch;
    ch=(ch-3);
    cout << ch;
    outfile<<ch;
    infile >> ch;
    ch=(ch-3);
    cout << ch;
    outfile<<ch;
    infile >> ch;
    ch=(ch-3);
    cout << ch;
    outfile<<ch;
    infile >> ch;
    ch=(ch-3);
    cout << ch;
    outfile<<ch;
    infile >> ch;
    ch=(ch-3);
    cout << ch;
    outfile<<ch;
    infile >> ch;
    ch=(ch-3);
    cout << ch;
    outfile<<ch;
    infile >> ch;
    ch=(ch-3);
    cout << ch;
    outfile<<ch;
    infile >> ch;
    ch=(ch-3);
    cout << ch;
    outfile<<ch;
    infile >> ch;
    ch=(ch-3);
    cout << ch;
    outfile<<ch;
    infile >> ch;
    ch=(ch-3);
    cout << ch;
    //close files
    infile.close();
    outfile.close();
return 0;

}

the output the grader uses is I love Spam�

Whether your program uses loops has nothing to do with whether it handles non-ASCII input.

I found this at cplusplus.com

As part of the iostream library, the header file <iostream> declares certain objects that are used to perform input and output operations on the standard input and output.

They are divided in two sets: narrow-oriented objects, which are the popular cin, cout, cerr and clog and their wide-oriented counterparts, declared as wcin, wcout, wcerr and wclog.

The "wide-oriented" variants don't necessarily support full unicode, but might be sufficient for your needs.

Are you specifically not supposed to use loops? Your code as written is already nearly impossible to maintain, and won't handle an input string longer than 11 (or however many) characters....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.