title: C++ Validating Comma Placement in Numerical Input
body: <p>I'm taking my first cs course and I'm currently learning the different ways to validate numerical inputs. Below is a bool function I wrote to check comma positions, but when I enter 65,000 it thinks the comma is in the wrong place.</p>
  <pre><code>bool commas(string input) {
      bool commas = true;
      long len = input.length();
      int counter = 0;
  
      for(int z = len-1; z &gt;= 0; --z) {
          if(counter == 3) {
              if(input[z] != ',') {
                  commas = false;
              counter = 0;
              }
          }
          else {
              if(input[z] == ',') {
                  commas = false;
              }
              else {
                  ++counter;
              }
          }
      }
      return commas;
  }
  </code></pre>