uche skrev:
Hello all!!
Is there an algorithm out there that will allow you to go to a
specific line in a .txt...and start outputing to the screen at that
line until end of record
End of file?
>
Here is a code that i implemented...
while(istrm1.peek() != EOF)
{
++count;
if(count==RBNx)
What is 'RBNx'?
{
for(int i = 0 ; i < endofRec; i++)
{
istrm1.getline(line,512);
cout<<line<<endl;
}
istrm1.seekg(ios::clear,ios::begin);
istrm1.clear();
break;
}
istrm1.ignore(128, '\n');
}
Your posted code is rather incomplete.
#include <fstream>
#include <string>
#include <ostream>
#include <algorithm>
void fskip(std::istream & in, unsigned nolines) {
std::string rbuf;
while(nolines-- && std::getline(in,rbuf).good());
}
void fout(std::istream & in) {
std::copy(std::istream_iterator<char>(in),
std::istream_iterator<char>(),
std::ostream_iterator<char>(std::cout));
}
int main(int argc, char* argv[])
{
std::ifstream in("text");
fskip(in,3);
fout(in);
return 0;
}