A
Angus
Hello
Here is my code
std::ifstream myfile;
std::string line;
long begin,end;
myfile.open("c:\\IPlog.txt");
if (myfile.is_open())
{
while (! myfile.eof() )
{
std::getline (myfile,line);
std::cout << line << std::endl;
}
myfile.seekg(0);
begin = myfile.tellg();
myfile.seekg (0, std::ios::end);
end = myfile.tellg();
std::cout << "size is: " << (end-begin) << " bytes.\n";
myfile.close();
}
I only want to open the file once and get the file size then get the
contents.
Trouble is by getting to eof with extracting file contents how do I then get
back to the beginning of the file. I thought myfile.seekg(0); did that?
Angus
Here is my code
std::ifstream myfile;
std::string line;
long begin,end;
myfile.open("c:\\IPlog.txt");
if (myfile.is_open())
{
while (! myfile.eof() )
{
std::getline (myfile,line);
std::cout << line << std::endl;
}
myfile.seekg(0);
begin = myfile.tellg();
myfile.seekg (0, std::ios::end);
end = myfile.tellg();
std::cout << "size is: " << (end-begin) << " bytes.\n";
myfile.close();
}
I only want to open the file once and get the file size then get the
contents.
Trouble is by getting to eof with extracting file contents how do I then get
back to the beginning of the file. I thought myfile.seekg(0); did that?
Angus