title: How compare vector size with an integer?
body: <p>I am using the following code to throw an error if the size of vector (declared as <code>vector&lt;int&gt; vectorX</code>) is is different than intended.</p>
  
  <pre><code>vector&lt;int&gt; vectorX;
  int intendedSize = 10;
  // Some stuff here
  if((int)(vectorX.size()) != (intendedSize)) {
      cout &lt;&lt; "\n Error! mismatch between vectorX "&lt;&lt;vectorX.size()&lt;&lt;" and intendedSize "&lt;&lt;intendedSize;
      exit(1);
  }
  </code></pre>
  
  <p>The <code>cout</code> statement shows the same size for both. <strong>The comparison is not showing them to be equal</strong>.</p>
  
  <p>Output is <code>Error! mismatch between vectorX 10 and intendedSize 10</code></p>
  
  <p>Where is the error? Earlier I tried <code>(unsigned int)(intendedSize)</code> but that too showed them unequal.</p>