title: Read from a file with blank spaces in C++
body: <p>I am reading from a file and passing the front of the array(pointer) back into my main function.  The problem I am having is that it is not copying the blank spaces in between the words. For example <code>Hello Hello</code> comes out as <code>HelloHello</code>.</p>
  
  <p>I started by using <code>getLine</code> instead and ran into the problems of size of the file.  I set it to 500 because no files will be larger than 500, however most files will be below 500 and I am trying to get the exact size of the file.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>char infile()
  {
     const int SIZE=500;
     char input[SIZE];
     char fromFile; 
     int i=0;
  
     ifstream readFile;
     readFile .open("text.txt");
     while(readFile&gt;&gt;fromFile)
     {
       input[i]=fromFile;
       i++;
     }
     cout&lt;&lt;endl;
     returnArray=new char[i];//memory leak need to solve later
     for(int j=0;j&lt;i;j++)
     {
        returnArray[j]=input[j];
        cout&lt;&lt;returnArray[j];
      }
      cout&lt;&lt;endl;
    }
    return returnArray[0];
  }
  </code></pre>