title: Length of a char array
body: <p>I have the code like this:</p>
  
  <pre><code>#include &lt;iostream.h&gt;
  #include &lt;fstream.h&gt;
  void main()
  {
      char dir[25], output[10],temp[10];
      cout&lt;&lt;"Enter file: ";
      cin.getline(dir,25);           //like C:\input.txt
      ifstream input(dir,ios::in);
      input.getline(output,'\eof');
      int num = sizeof(output);
      ofstream out("D:\\size.txt",ios::out);
      out&lt;&lt;num;
  }
  </code></pre>
  
  <p>I want to print the length of the output. But it always returns the number 10 (the given length) even if the input file has only 2 letters ( Like just "ab"). I've also used strlen(output) but nothing changed. How do I only get the used length of array?</p>
  
  <p>I'm using VS C++ 6.0</p>