title: Is there a safe version of strlen?
body: <p><a href="http://en.cppreference.com/w/cpp/string/byte/strlen" rel="noreferrer">std::strlen</a> doesn't handle c strings that are not \0 terminated. Is there a safe version of it?</p>
  
  <p>PS I know that in c++ std::string should be used instead of c strings, but in this case my string is stored in a shared memory.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Ok, I need to add some explanation.  </p>
  
  <p>My application is getting a string from a shared memory (which is of some length), therefore it could be represented as an array of characters. If there is a bug in the library writing this string, then the string would not be zero terminated, and the strlen could fail.</p>