I have a simple C ++ program that reads a file line by line. Some lines contain more than 20,000 characters. The following program can only read 4095 characters of this large line. I think this is due to buffer size limitation. What is the solution for reading large lines?
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
string line;
ifstream myfile ("new.fasta");
if (myfile.is_open())
{
while ( getline (myfile,line) )
{
cout << line.length() << '\n';
}
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
source
share