c++ get one line data in txt file
<p>I want to read  data from a txt file, but i am not able to get it. I am new to c++.
Here is my code, but it does not work. I used getline(),</p>

<pre><code> ifstream inFile;
 string sPassWord;
 inFile.open("QdatPassWordconfig.config");
 inFile.seekg(0,ios::end);
 int length=inFile.tellg();

  if (inFile.is_open())
  {
      while (!inFile.eof())
      {
              getline(inFile,sPassWord);
               cout&lt;&lt;sPassWord&lt;&lt;endl;
      }

         cout&lt;&lt;"get data from txt file"&lt;&lt;endl;
         // here ,I cannot read data from file
         cout&lt;&lt;sPassWord&lt;&lt;endl;
  }

 if(!inFile.is_open() || length==0)
  {
      cout&lt;&lt;"file is create or write"&lt;&lt;endl;
      sPassWord="BdsWUjT26";
      ofstream outFile;
      outFile.open("QdatPassWordconfig.config");
      outFile&lt;&lt;sPassWord&lt;&lt;endl;
      outFile.close();
  }
   inFile.close();
  cout&lt;&lt;sPassWord&lt;&lt;endl;
</code></pre>
