If anybody could help me I would appreciate it.
I am trying to decode using the following:
Key stringOCTRZSIENVWABFGHJKLMPQUXY
Decode string: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Infile string: CDMLEFB LIR AFMBLDEBK DJR ZMWW FZ IEWWK
Infile string should decode to: CAUTION THE MOUNTAINS ARE FULL OF HILLS
What I have been trying to do is find the position of the incoming letters from the file. My problem is that I only get the first letter of the infile (C being at position 2, which equals to C, the next one should be D at position 0, which equals to A, etc). If I add an index to "final", it gives me a compiler error. Maybe I'm going at it the wrong way? Please help!
char str[80];
char string3[27] = "DOCTRZSIENVWABFGHJKLMPQUXY";
char final[80];
int i;
char *pdest;
int result;
void main(void)
{
cls;
infile.open ("F1949.txt", ios::in);
while (infile)
{
infile.get (final[i]);
cout << final[i];
pdest = strstr( string3, final );
result = pdest - string3;
if( pdest != NULL )
{
cout << endl << final[i] << " found at position " << result << endl;
}
i++;
}
}