【发布时间】:2017-12-28 22:32:53
【问题描述】:
char* name[4];
int j=0;
while(cin.getline(name[j],80))//input given:you(ent)me(ent)he(ent)she
cout<<name[j++];
这段代码只读取一个字符串到一个换行符。它应该读取所有 4 个字符串并打印它们吗?这是使用 getline 输入字符串的好方法吗?
【问题讨论】:
-
你有一个指针数组,但是指针实际上在哪里point?
-
使用 std::vector 和 std::string。没有人有时间指点。