文本是这样的:
when i wake up the other side of the bed is cold my
fingers stretch out seeking prims warmth but finding
only the rough canvas cover of the mattress she
must have had bad dreams and climbed in with our
mother of course she did this is the day of the
reaping
i prop myself up on one elbow theres enough light in
怎么实现这个: arry[0].word = when array[1].word = I array[2].word=wake
我试着用了getline: while(getline(ifs,useless,' ')
但是这样的话会把很多空格,换行一起录入进去,有没有办法只单单录入单词?
可以用string,遇到空格会自动换下一个。
#include<iostream>
int n;
string s[1001];
int main(){
freopen("text.in","r",stdin);
for (int i=1; i<=n; i++) cin>>s[i];
return 0;
}
#include<iostream>
int n;
string s[1001];
int main(){
freopen("text.in","r",stdin);
for (int i=1; i<=n; i++) cin>>s[i];
return 0;
}
温馨提示:答案为网友推荐,仅供参考