出于某种原因,如果最后一行包含的字符少于缓冲区,我的程序不会打印文本文件的最后一行
#include <iostream>
#include <iomanip>
#include <fstream>
int main()
{
std::ifstream read("test.txt");
char buffer[12];
while(!read.eof())
{
read.getline(buffer,11);
if(!read.eof())
std::cout<<buffer<<'\n';
read.clear();
}
read.close();
return 0;
}