我有一个简单的C ++程序,它逐行读取文件。有些行包含超过20000个字符。以下程序只能读取这些大行的4095个字符。我认为这是由于缓冲区大小的限制。阅读大字句的解决方案是什么?
// reading a text file
#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;
}
Run Code Online (Sandbox Code Playgroud)