title: C++: How to iterate over each char in a string?
body: <p>I have a string where I need to grab each char and do some checking.</p>
  
  <pre><code>std::string key = "test"
  int i = 0;
  while (key.at(i))
  {
      // do some checking
      i++;
  }
  </code></pre>
  
  <p>The problem with this is, eventually the index i will be out of range, so the system will crash. How can I fix this?</p>
  
  <p>Thanks!</p>