I am working on an assignment for my intro to programming class. The program is supposed to read input from a file, encrypt it, then write the encrypted data to a new file. The code is still a work in progress, but I've reached a major roadblock.
I'm using a for loop to encrypt each character in a line individually. Every time I try to run the program, I get a fatal error in this for loop, saying that the string subscript is out of range. I have been working on this error for the better part of two hours, and cannot see anything different about this loop than any other for loop I've written in the past.
As I see, It may have something wrong with for (int index = 0; index < inLine.size(); index++).
the type of index is int, which is signed, whereas the type of inLine.size() is string::size_type which is unsigned. the result of "index < inLine.size()" may be unexpected.
Maybe you could try to use for (decltype(inLine.size()) index = 0; index < inLine.size(); index++).