<分区>
我正在尝试使用 for 循环将 4 个字符串放入一个数组中。 for 循环结束后,我尝试使用 for 循环显示 4 个字符串。我不知道我的错误在哪里。任何帮助和指导将不胜感激。
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main()
{
//declare variables
string array[4] ;
cout<<"input 4 strings"<<endl;
for (int i=1; i<4; i++)
{
getline(cin,array[i]);
}
cout << "here are your 4 strings" << endl;
for (int j=0; j<4; j++)
{
cout<<array[j]<<endl;
}
system("pause");
return 0;
} // end of main function