c++如何输入一个不定长的字符串数组

#include
#include
#include
using namespace std;

int main(){
	vector<string> strs;
	string s;
	while(cin>>s){
		strs.push_back(s);
	}
	cout<<strs.size();
	return 0;	
}

c++如何输入一个不定长的字符串数组_第1张图片
每次输入字符串敲一下回车,继续输入下一个字符串,输入完毕后,ctrl+z,结束。

你可能感兴趣的:(c++)