title: why wont my for loop execute when using strings
body: <p>I am writing a program in C++ that formats phone numbers into international format. I used visual studios to compile my code and it indicates I do not have any errors, yet the for loop on line 21 keeps getting skipped and I cannot for the life of me figure out why. Any ideas?</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  int main()
  {
      string phonNumber; //to hold string
      string formattedNum = &quot;+1-&quot;; //to hold international format
      int count = 0; //to hold count index
      int i = 0; //to hold number index
  
      cout &lt;&lt; &quot;Please enter a phone number: &quot;; //asks for phone number
      getline(cin, phonNumber); //use getline to get number and assign it to phonNumber
  
      int numOfDigits = phonNumber.length(); //gets length of phone number
  
      for (i = 0; i &gt; numOfDigits || count &gt; 10; i++) //runs a loop through the digits
      {
          if (phonNumber[i] &lt;= '9' &amp;&amp; phonNumber[i] &gt;= '0') //reads only numbers
          {
              string formattedNum = formattedNum + phonNumber[i];
              if (count == 4) //4th digit is -
              {
                  string formattedNum = formattedNum + &quot;-&quot;;
              }
              if (count == 7) //7th digit is -
              {
                  string formattedNum = formattedNum + &quot;-&quot;;
              }
              count++;
              i++;
          }
          numOfDigits = count;
      }
  
      while (!(count &gt; 10)) {
          formattedNum = formattedNum + &quot;x&quot;;
          count++;
      }
      cout &lt;&lt; &quot;The properly formatted number is &quot; &lt;&lt; formattedNum &lt;&lt; endl;
      return 0;
  }
  </code></pre>