I have a string where I need to grab each char and do some checking:
std::string key = "test"
int i = 0;
while (key.at(i))
{
// do some checking
i++;
}
The problem here is that, eventually, the index i will be out of range, so the system will crash. How can I fix this?
1 Answer