so i have a program that reads in a file and decodes the file then spits out the message. the symbol @ followed by an int will declare what amount i need to shift the alphabet by. i have all of that working fine. my problem is if there isn't an int following the symbol, the program displays an error i made. i need it to discard the rest of the message until it reaches the # symbol. when it reaches that, it will start behaving like normal again. i would appreciate any help.
2007-10-26
10:56:52
·
2 answers
·
asked by
nadsoil05
1
in
Computers & Internet
➔ Programming & Design
here is the code if have written -
while (inFile)
{
inFile.get (ch); //looks through the file character by character
if (ch == shiftdown)
{
inFile >> keytemp;
if (inFile.fail()) //no int following special symbol
{
inFile.clear();
cout << "*** Error Code 2 -- No shift value as expected ***";
break;
}
key = 0 - keytemp;
if (key < -26)
{
key = key % 26;
}
}
so what the code needs to do is if there is no number after the symbol to shiftdown, it needs to print that error message and then finish the line until the # sign.all of those characters just need to be thrown away and not displayed. once it gets there, it needs to start reading the new line again and apply the shift
2007-10-26
13:24:18 ·
update #1