title: How to get the size of the used space in an array? (NOT sizeof); c++
body: <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  int main()
  {
      char arr[200];
      while(1) {
          cin &gt;&gt; arr;
          int i = sizeof(arr);
          cout &lt;&lt; "The arr input is "&lt;&lt; arr 
               &lt;&lt; " and the size of the array is "&lt;&lt; i &lt;&lt; endl;
      }
      return 0;
  }
  </code></pre>
  
  <p>For the input of 34,
  This code outputs :The arr input is 34 and the size of the array is 200 </p>
  
  <hr>
  
  <p>while I want it to get the size of the used space of the array . So for The last input i want it to output :The arr input is 34 and the size of the array is 2</p>
  
  <hr>
  
  <p>Can someone tell me how?</p>