Decryption assignment help!

So, I have an assignment for school in which the user enters a filename and three integers from 0 to 26, using these integers one by one the program is supposed to decrypt a message from the file. however, mine wont work when it hits a whitespace, and when i try to use noskipws, the program stops at the first whitespace. Can anyone help me fix it.

const char BLANK = ' ';
char ans, letter;
string filename;
int currentNum = 0;
int x=0;
int lineLoop=0;
int first, second, third;
string lineInFile;
char eachChar;
string alphabetCaps = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabetLower = "abcdefghijklmnopqrstuvwxyz";

the user enters the integers and filename here.

int decryptionArray[3] = {first, second, third};
do {
infile >> noskipws >> lineInFile >> ws;
for (lineLoop=0; lineLoop<lineInFile.length(); lineLoop++)
{
eachChar = lineInFile[lineLoop];

for (int letterChecks = 0; letterChecks < 26; letterChecks++){

if (lineInFile[lineLoop] == alphabetCaps[letterChecks]) {
if (letterChecks - decryptionArray[currentNum] < 0)
eachChar = alphabetCaps[letterChecks + 26 - decryptionArray[currentNum]];
else
eachChar = alphabetCaps[letterChecks - decryptionArray[currentNum]];
}
else if (lineInFile[lineLoop] == alphabetLower[letterChecks]) {
if (letterChecks - decryptionArray[currentNum] < 0)
eachChar = alphabetLower[letterChecks + 26 - decryptionArray[currentNum]];
else
eachChar = alphabetLower[letterChecks - decryptionArray[currentNum]];
}
}

currentNum++;
if (currentNum > 2)

currentNum = 0;


cout << eachChar;
}
infile >> lineInFile;
}while(infile);


infile.close ();
Ok I solved the whitespace problem, but now after a space, the decryption falls apart until a little while later. what do I do?
I corrected the whitespace problem by replacing

infile >> noskipws >> lineInFile >> ws;

with

do {
cout << BLANK;
}while(letter == BLANK);
Topic archived. No new replies allowed.