c++小程序问题求教?
#include <iostream>#include <string>
using namespace std;
struct StudentInfo //定义学生信息机构体
{
string strName;
int chinese;
int math;
int english;
};
StudentInfo student[3];
void StudentInput() //学生信息输入函数
{
int i = 0;
for(i;i<3;i++)
{
cout<<"Enter the "<<i+1<<" student information.\n"<<endl;
cout<<"Enter Name:"<<endl;
cin>>student[i].strName;
cout<<"Enter chinese"<<endl;
cin>>student[i].chinese;
cout<<"Enter math"<<endl;
cin>>student[i].math;
cout<<"Enter english"<<endl;
cin>>student[i].english;
}
}
void StudentOut()//学生信息输出函数
{
for(int i=0;i<3;i++)
{
cout<<"The "<<i+1<<" student information"<<endl;
cout<<"Name : "<<student[i].strName<<"\n"<<endl;
cout<<"Chinese : "<<student[i].chinese<<"\n"<<endl;
cout<<"Math : "<<student[i].math<<"\n"<<endl;
cout<<"English : "<<student[i].english<<"\n"<<endl;
}
}
int main()
{
StudentInput();
StudentOut();
cin.get();
return 0;
}
我在输入3个学生的信息后,敲回车程序直接退出了,未能显示出输入的学生信息。