title: Break statement not working
body: <p>This program should store the number of characters of name in the variable str_length (where name &lt; 50 characters terminated by a ".") I'm baffled as to why this code only spits out the first character, meaning it breaks from the loop when i = 0, for a name such as "Jonathan." Shouldn't it parse through the string until it finds the ".", only then breaking from the for loop?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstring&gt;
  
  using namespace std;
  
  int main()
  {
  
   string name;
   int str_length;
  
   cout &lt;&lt; "What's your name" &lt;&lt; endl;
  
   cin &gt;&gt; name;
  
   for (int i = 0; i &lt; 50; i++)
   {
       cout &lt;&lt; name[i];
       if (name[i] == '.')
          str_length = i;
          break;         
   }
  
   cout &lt;&lt; endl;
  
   system("PAUSE");
  
   return 0;  
   }
  </code></pre>