Im creating a void that would read and decrypt some characters in a text file. 10 has been subtracted from the ASCII code, but I feel like im doing this function wrong. EDIT: its supposed to do the first 8 letters, hence the counter.
1 2 3 4 5 6 7 8
void decrypt(){
for(int ctr = 0; ctr < 9; ctr++){
char letter;
cin.get(letter);
int x = letter - 10;
cin >> x;
}
}
... nine steps, even if you never get to ctr = 9 (because 9 is not less than itself).
This means that you read nine letters, instead of eight.
cin >> x;
This means you read (input) a new value into x, discarding the original value.
Yet what you actually want is to print (output) it, do you not?