title: Am I correct that strcmp is equivalent (and safe) for literals?
body: <p>We all know the trouble overflows can cause, and this is why strn* exist - and most of the time they make sense. However, I have seen code which uses strncmp to compare commandline parameters like so:</p>
  
  <pre><code>if(... strncmp(argv[i], "--help", 6) == 0
  </code></pre>
  
  <p>Now, I would have thought that this is unnecessary and perhaps even dangerous (for longer parameters it would be easy to miscount the characters in the literal).</p>
  
  <p>strncmp stops on nulls, and the code already assumes argv[i] is null-terminated. Any string literal is guaranteed to be null-terminated, so why not use strcmp?</p>
  
  <p>Perhaps I'm missing something, but I've seen this a few times and this time it intrigued me enough to ask.</p>