title: C++ Displaying a Text File...("Echo" a Text File)
body: <p>So I'm really stuck trying to figured this bug on the program that is preventing me from displaying the text of my program..</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;fstream&gt;
  #include &lt;sstream&gt;
  #include &lt;string&gt;
  #include &lt;stdio.h&gt;
  using namespace std;
  
  int main ()
  {
  ifstream infile;
  ofstream offile;
  
  char text[1024];
  cout &lt;&lt;"Please enter the name of the file: \n";
  cin &gt;&gt; text;
  
  infile.open(text);
  
  string scores; // this lines...
  
  getline(infile, scores, '\0'); // is what I'm using...
  
  cout &lt;&lt; scores &lt;&lt; endl; // to display the file...
  </code></pre>
  
  <hr>
  
  <pre><code>string name1;
  int name2;
  string name3;
  int name4;
  infile &gt;&gt; name1;
  infile &gt;&gt; name2;
  infile &gt;&gt; name3;
  infile &gt;&gt; name4;
  
  cout &lt;&lt; "these two individual with their age add are" &lt;&lt; name2 + name4 &lt;&lt;endl;
  
  // 23 + 27
  
  //the result I get is a bunch of numbers...
  
  return 0;
  
  }
  </code></pre>
  
  <p>Is there any way cleaner or simple method i can used to display the file ?</p>
  
  <p>All the method in the internet are difficult to understand or keep track due to
  the file is open in loop..</p>
  
  <p>I want a program that you type the name of the file and displays the file
  the file will contain the following...</p>
  
  <pre><code>jack 23 
  smith 27
  </code></pre>
  
  <p>Also I need to obtain data from the file now I'm using the above code to obtain that information from the file...</p>