title: How do I fill an array with characters from user input, while counting how many array indexes have been used? (using cin.get)
body: <p>I need to use the get function and count how many indexes have been filled I have been running into a couple problems.</p>
  
  <p>It seems that using cin.get in this way only allows me to fill the array and doesn't allow me to count how many variables in the array have been filled:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  int main()
  {
     char line[25];
     cout &lt;&lt; " Type a line terminated by enter\n&gt;";
     cin.get( line, 25 );
  
  }
  </code></pre>
  
  <p>I have a feeling that I need to use a for loop such as the one below, but the problem with this is it doe not end with enter, the user has to fill the whole array and I need to be able to enter any amount of characters under the limit. Also the example did not use sentinel value, so though it would seem to solve this, it doesn't seem to be the solution.</p>
  
  <pre><code>void fill_array(char array[], int max_count, int&amp; num_used)
  {
      char input;
      int index = 0;
  
      cout &lt;&lt; "Enter a text string to test" &lt;&lt; endl;
      for( index = 0;index &lt; max_count; index++)
      {
           cin.get(input);
           array[index] = input;
           num_used++;
      }
  }
  </code></pre>