- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: The file pointer can not come back when meet E...
Operating System - Linux
1753837
Members
9564
Online
108806
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2001 02:56 PM
03-09-2001 02:56 PM
The file pointer can not come back when meet EOF?
When I use lFileLength = IN.tellg(); to get the position of file stream and lster use
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.
Why?
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.
Why?
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2001 03:31 PM
03-09-2001 03:31 PM
Re: The file pointer can not come back when meet EOF?
//When pointor reach EOF, you cannot get it back!!!!?????
#define MAX_LINE 500
#include
int main (){
long int lFileLength;
long int lFilePosition;
char sRaw[MAX_LINE];
int iLine;
ifstream IN;
IN.open("testfile.txt", ios::in, 0);
if (!IN){
cout<< "Cannot open validated file. \n";
return 0;
}
IN.seekg(0, ios::end);
lFileLength = IN.tellg();
IN.seekg(0, ios::beg);
while (!IN.eof()){ //the biggest loop
IN.getline(sRaw, 255);
if(IN.eof()){
break;
}
cout<
lFilePosition = IN.tellg();
iLine=0;
while(iLine<5 ){
if(IN.eof()){
break;
}
IN.getline(sRaw, MAX_LINE);
iLine++;
cout<<" "<
}
//return to the old position
IN.seekg(lFilePosition);
}
IN.close();
return 1;
}
#define MAX_LINE 500
#include
int main (){
long int lFileLength;
long int lFilePosition;
char sRaw[MAX_LINE];
int iLine;
ifstream IN;
IN.open("testfile.txt", ios::in, 0);
if (!IN){
cout<< "Cannot open validated file. \n";
return 0;
}
IN.seekg(0, ios::end);
lFileLength = IN.tellg();
IN.seekg(0, ios::beg);
while (!IN.eof()){ //the biggest loop
IN.getline(sRaw, 255);
if(IN.eof()){
break;
}
cout<
lFilePosition = IN.tellg();
iLine=0;
while(iLine<5 ){
if(IN.eof()){
break;
}
IN.getline(sRaw, MAX_LINE);
iLine++;
cout<<" "<
}
//return to the old position
IN.seekg(lFilePosition);
}
IN.close();
return 1;
}
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP