<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: The file pointer can not come back when meet EOF? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/the-file-pointer-can-not-come-back-when-meet-eof/m-p/2503488#M80090</link>
    <description>//When pointor reach EOF, you cannot get it back!!!!????? &lt;BR /&gt;                  #define MAX_LINE 500 &lt;BR /&gt;                  #include &lt;BR /&gt;&lt;BR /&gt;                  int main (){ &lt;BR /&gt;&lt;BR /&gt;                  long int lFileLength; &lt;BR /&gt;&lt;BR /&gt;                  long int lFilePosition; &lt;BR /&gt;&lt;BR /&gt;                  char sRaw[MAX_LINE]; &lt;BR /&gt;&lt;BR /&gt;                  int iLine; &lt;BR /&gt;&lt;BR /&gt;                  ifstream IN; &lt;BR /&gt;&lt;BR /&gt;                  IN.open("testfile.txt", ios::in, 0); &lt;BR /&gt;&lt;BR /&gt;                  if (!IN){ &lt;BR /&gt;&lt;BR /&gt;                  cout&amp;lt;&amp;lt; "Cannot open validated file. \n"; &lt;BR /&gt;&lt;BR /&gt;                  return 0; &lt;BR /&gt;&lt;BR /&gt;                  } &lt;BR /&gt;&lt;BR /&gt;                  IN.seekg(0, ios::end); &lt;BR /&gt;&lt;BR /&gt;                  lFileLength = IN.tellg(); &lt;BR /&gt;&lt;BR /&gt;                  IN.seekg(0, ios::beg); &lt;BR /&gt;&lt;BR /&gt;                  while (!IN.eof()){ //the biggest loop &lt;BR /&gt;&lt;BR /&gt;                  IN.getline(sRaw, 255); &lt;BR /&gt;&lt;BR /&gt;                  if(IN.eof()){ &lt;BR /&gt;&lt;BR /&gt;                  break; &lt;BR /&gt;&lt;BR /&gt;                  } &lt;BR /&gt;&lt;BR /&gt;                  cout&amp;lt;&lt;SRAW&gt;&lt;/SRAW&gt;&lt;BR /&gt;                  lFilePosition = IN.tellg(); &lt;BR /&gt;&lt;BR /&gt;                  iLine=0; &lt;BR /&gt;&lt;BR /&gt;                  while(iLine&amp;lt;5 ){ &lt;BR /&gt;&lt;BR /&gt;                  if(IN.eof()){ &lt;BR /&gt;&lt;BR /&gt;                  break; &lt;BR /&gt;&lt;BR /&gt;                  } &lt;BR /&gt;&lt;BR /&gt;                  IN.getline(sRaw, MAX_LINE); &lt;BR /&gt;&lt;BR /&gt;                  iLine++; &lt;BR /&gt;&lt;BR /&gt;                  cout&amp;lt;&amp;lt;" "&amp;lt;&lt;SRAW&gt;&lt;/SRAW&gt;&lt;BR /&gt;                  } &lt;BR /&gt;&lt;BR /&gt;                  //return to the old position &lt;BR /&gt;&lt;BR /&gt;                  IN.seekg(lFilePosition); &lt;BR /&gt;&lt;BR /&gt;                  } &lt;BR /&gt;&lt;BR /&gt;                  IN.close(); &lt;BR /&gt;&lt;BR /&gt;                  return 1; &lt;BR /&gt;                  } &lt;BR /&gt;</description>
    <pubDate>Fri, 09 Mar 2001 23:31:32 GMT</pubDate>
    <dc:creator>Zhidian Du</dc:creator>
    <dc:date>2001-03-09T23:31:32Z</dc:date>
    <item>
      <title>The file pointer can not come back when meet EOF?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/the-file-pointer-can-not-come-back-when-meet-eof/m-p/2503487#M80089</link>
      <description>When I use  lFileLength = IN.tellg();  to get the position of file stream and lster use &lt;BR /&gt; IN.seekg(lFilePosition);   to relocate the pointor to old position, it OK unless the pointor does not reach EOF. If the pointor reach EOF, it never come back even use IN.seekg(lFilePosition); The compiler is g++ in Linux.  Using other compiler, such as CC in SUNOS5.8 is OK.&lt;BR /&gt;&lt;BR /&gt;Why?</description>
      <pubDate>Fri, 09 Mar 2001 22:56:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/the-file-pointer-can-not-come-back-when-meet-eof/m-p/2503487#M80089</guid>
      <dc:creator>Zhidian Du</dc:creator>
      <dc:date>2001-03-09T22:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: The file pointer can not come back when meet EOF?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/the-file-pointer-can-not-come-back-when-meet-eof/m-p/2503488#M80090</link>
      <description>//When pointor reach EOF, you cannot get it back!!!!????? &lt;BR /&gt;                  #define MAX_LINE 500 &lt;BR /&gt;                  #include &lt;BR /&gt;&lt;BR /&gt;                  int main (){ &lt;BR /&gt;&lt;BR /&gt;                  long int lFileLength; &lt;BR /&gt;&lt;BR /&gt;                  long int lFilePosition; &lt;BR /&gt;&lt;BR /&gt;                  char sRaw[MAX_LINE]; &lt;BR /&gt;&lt;BR /&gt;                  int iLine; &lt;BR /&gt;&lt;BR /&gt;                  ifstream IN; &lt;BR /&gt;&lt;BR /&gt;                  IN.open("testfile.txt", ios::in, 0); &lt;BR /&gt;&lt;BR /&gt;                  if (!IN){ &lt;BR /&gt;&lt;BR /&gt;                  cout&amp;lt;&amp;lt; "Cannot open validated file. \n"; &lt;BR /&gt;&lt;BR /&gt;                  return 0; &lt;BR /&gt;&lt;BR /&gt;                  } &lt;BR /&gt;&lt;BR /&gt;                  IN.seekg(0, ios::end); &lt;BR /&gt;&lt;BR /&gt;                  lFileLength = IN.tellg(); &lt;BR /&gt;&lt;BR /&gt;                  IN.seekg(0, ios::beg); &lt;BR /&gt;&lt;BR /&gt;                  while (!IN.eof()){ //the biggest loop &lt;BR /&gt;&lt;BR /&gt;                  IN.getline(sRaw, 255); &lt;BR /&gt;&lt;BR /&gt;                  if(IN.eof()){ &lt;BR /&gt;&lt;BR /&gt;                  break; &lt;BR /&gt;&lt;BR /&gt;                  } &lt;BR /&gt;&lt;BR /&gt;                  cout&amp;lt;&lt;SRAW&gt;&lt;/SRAW&gt;&lt;BR /&gt;                  lFilePosition = IN.tellg(); &lt;BR /&gt;&lt;BR /&gt;                  iLine=0; &lt;BR /&gt;&lt;BR /&gt;                  while(iLine&amp;lt;5 ){ &lt;BR /&gt;&lt;BR /&gt;                  if(IN.eof()){ &lt;BR /&gt;&lt;BR /&gt;                  break; &lt;BR /&gt;&lt;BR /&gt;                  } &lt;BR /&gt;&lt;BR /&gt;                  IN.getline(sRaw, MAX_LINE); &lt;BR /&gt;&lt;BR /&gt;                  iLine++; &lt;BR /&gt;&lt;BR /&gt;                  cout&amp;lt;&amp;lt;" "&amp;lt;&lt;SRAW&gt;&lt;/SRAW&gt;&lt;BR /&gt;                  } &lt;BR /&gt;&lt;BR /&gt;                  //return to the old position &lt;BR /&gt;&lt;BR /&gt;                  IN.seekg(lFilePosition); &lt;BR /&gt;&lt;BR /&gt;                  } &lt;BR /&gt;&lt;BR /&gt;                  IN.close(); &lt;BR /&gt;&lt;BR /&gt;                  return 1; &lt;BR /&gt;                  } &lt;BR /&gt;</description>
      <pubDate>Fri, 09 Mar 2001 23:31:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/the-file-pointer-can-not-come-back-when-meet-eof/m-p/2503488#M80090</guid>
      <dc:creator>Zhidian Du</dc:creator>
      <dc:date>2001-03-09T23:31:32Z</dc:date>
    </item>
  </channel>
</rss>

