自考新教材-p293

源程序:

#include<iostream>

using namespace std;

int main()

{

char buf[10];

int i = 0;

while (cin.getline(buf, 10))   //若输入流的一行超过9个字符,则会出错

cout << ++i << ":" << buf << endl;

cout << "last:" << buf << endl;

system("pause");

return 0;

}

运行结果:

原文地址:https://www.cnblogs.com/duanqibo/p/12236083.html