输出中文名字是乱码
void Calculate::CalMain()
{
ReadDate();
CalDate();
OutDate();
}
void Calculate::ReadDate()
{
char C_Temp[200];
ifstream inf("成绩单数据1.txt",ios::in);
while (inf.eof()==0)
{
inf>>C_Temp;
m_LIST.ClassName=C_Temp;
inf>>C_Temp;
m_LIST.StudentName=C_Temp;
inf>>C_Temp;
m_LIST.StudentNO=C_Temp;
inf>>m_LIST.ChineseScore;
inf>>m_LIST.MathScore;
inf>>m_LIST.EnglishScore;
vec_LIST.push_back(m_LIST);
}
inf.close();
}
void Calculate::CalDate()
{
int in_ROW=vec_LIST.size();
for (int i=0;i<in_ROW;i++)
{
vec_LIST[i].AllScore=vec_LIST[i].ChineseScore+vec_LIST[i].EnglishScore+vec_LIST[i].EnglishScore;
}
}
void Calculate::OutDate()
{
ofstream outf("成绩单数据输出.txt",ios::out);
int in_ROW=vec_LIST.size();
for (int i=0;i<in_ROW;i++)
{
outf<<vec_LIST[i].StudentName<<" "<<vec_LIST[i].AllScore<<endl;
}
outf.close();
}
断点调试的时候,显示的都正常。就是在输出的TXT格式的文件中,中文名字乱码。其他都正常
[解决办法]
注意文件的编码格式与IDE的一致。