//Program to terminate the input by ctrl-c
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
vector<string> vec;
string word;
while (cin >> word)
vec.push_back(word);
cout << endl << endl;
auto beg = vec.begin();
while (beg != vec.end())
{
//to print the vector
cout << *beg << endl;
beg++;
}
}
當減少印刷機控制-c終止的輸入流...當我使用Ctrl-C終止輸入,輸出在Visual Studio 2013
ankur
anshu
singh
ankit
ashuto
ashu
我得到。 ...
ankur
anshu
si^CPress any key to continue . . .
只是爲了好奇,你還期望發生什麼? – user463035818
Ctrl + C終止程序,而不是輸入。改爲使用Ctrl + Z。 –