title: A warning - comparison between signed and unsigned integer expressions
body: <p>I am currently working through <em>Accelerated C++</em> and have come across an issue in exercise 2-3.</p>
  
  <p><strong>A quick overview of the program</strong> - the program basically takes a name, then displays a greeting within a frame of asterisks - i.e. Hello ! surrounded framed by *'s. </p>
  
  <p><strong>The exercise</strong> - In the example program, the authors use <code>const int</code> to determine the padding (blank spaces) between the greeting and the asterisks. They then ask the reader, as part of the exercise, to ask the user for input as to how big they want the padding to be.</p>
  
  <p>All this seems easy enough, I go ahead ask the user for two integers (<code>int</code>) and store them and change the program to use these integers, removing the ones used by the author, when compiling though I get the following warning;</p>
  
  <blockquote>
    <p>Exercise2-3.cpp:46: warning: comparison between signed and unsigned integer expressions</p>
  </blockquote>
  
  <p>After some research it appears to be because the code attempts to compare one of the above integers (<code>int</code>) to a <code>string::size_type</code>, which is fine. But I was wondering - does this mean I should change one of the integers to  <code>unsigned int</code>? Is it important to explicitly state whether my integers are signed or unsigned? </p>
  
  <pre><code> cout &lt;&lt; "Please enter the size of the frame between top and bottom you would like ";
   int padtopbottom;
   cin &gt;&gt; padtopbottom;
  
   cout &lt;&lt; "Please enter size of the frame from each side you would like: ";
   unsigned int padsides; 
   cin &gt;&gt; padsides;
  
   string::size_type c = 0; // definition of c in the program
   if (r == padtopbottom + 1 &amp;&amp; c == padsides + 1) { // where the error occurs
  </code></pre>
  
  <p>Above are the relevant bits of code, the <code>c</code> is of type <code>string::size_type</code> because we do not know how long the greeting might be - but why do I get this problem now, when the author's code didn't get the problem when using <code>const int</code>? In addition - to anyone who may have completed <em>Accelerated C++</em> - will this be explained later in the book?</p>
  
  <p>I am on Linux Mint using g++ via Geany, if that helps or makes a difference (as I read that it could when determining what <code>string::size_type</code> is). </p>