串果[200];
如何将字符串输入到数组中?
Example:
My mom has apples;
So , fruits array will contain:
fruits[0] = "My";
fruits[1] = "mom";
..........etc.
我该怎么做?
最佳答案
如果您从标准输入读取:
int i = 0;
for (string word; cin >> word; i++)
names[i] = word;
如果您从 string
中读取,请改用 istringstream
。
关于c++ - 如何将文本输入到字符串数组中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13455957/