问个关于cin的问题# Programming - 葵花宝典c*u2006-11-10 08:111 楼我想实现类似while (cin>>i){a.push_back(i);}怎么在用户回车的时候就终止循环呢?譬如i是int如果i是template class呢?谢谢
y*i2006-11-10 08:112 楼string line;while(true) {getline(cin, line);if(line == "")break;int i = atoi(line.c_str());a.push_back(i);}
t*t2006-11-10 08:113 楼use istringstream with template.【在 y****i 的大作中提到】: string line;: while(true) {: getline(cin, line);: if(line == ""): break;: : int i = atoi(line.c_str());: a.push_back(i);: }
c*u2006-11-10 08:114 楼can you give an example? Thx【在 t****t 的大作中提到】: use istringstream with template.