27 lines
519 B
C++
27 lines
519 B
C++
// 已知文件test.txt的内容如下:
|
||
// Good Morning!
|
||
// Good Night!
|
||
// Good Luck!
|
||
// 补充下面程序,使得输出结果如下:
|
||
// 1:Good Morning!
|
||
// 2:Good Night!
|
||
// 3:Good Luck!
|
||
|
||
#include <iostream>
|
||
#include <fstream>
|
||
using namespace std;
|
||
const int size = 100;
|
||
int main() {
|
||
char buf[::size];
|
||
// _______________
|
||
|
||
ifstream in("test.txt", ios::in);
|
||
|
||
int i = 1;
|
||
while (in.getline(buf, ::size)) {
|
||
// ____________________
|
||
|
||
cout << i <<":" << buf << endl;
|
||
i++;
|
||
}
|
||
} |