void printKLines(char *fileName)
{
const int k = 5;
string lines[k];
int size = 0;
ifstream myFile(fileName);
while (myFile.good()) {
getline(myFile, lines[size%k]);
size++;
}
for (int i=0; i<k; i++) {
cout<<lines[i]<<endl;
}
}
Write a method to print the last K lines of an input file using C++
最新推荐文章于 2023-03-13 16:36:24 发布