1
좋아요, 이것은 불완전한 프로그램의 작은 조각입니다. 프로그램은 입력 파일을 읽고 계산을 수행하여 출력 파일로 인쇄하지만 이상한 기호는 출력 파일에 있습니다.프로그램이 이상한 기호를 출력 파일에 인쇄합니다. C++
void printRecord (char name[20], char Id[20], ostream& outfile)
{
outfile << name << Id << endl;
}
int main()
{
ofstream outfile;
ifstream infile;
char file_nameI[21], file_nameO[21], name[20], Id[8];
float hworkgrade, grade1;
int deductions;
cout << "Please enter name of input file: ";
cin >> file_nameI;
infile.open(file_nameI);
if (!infile)
{
cout << "Could not open input file \n";
return 0;
}
cout << "Please enter name of output file: ";
cin >> file_nameO;
outfile.open(file_nameO);
if (!outfile)
{
cout << "Could not open output file \n";
return 0;
}
do
{
infile >> name >> Id;
cout<< name << Id;
hworkgrade = CalHworkGrade(grade1, infile);
printRecord(name, Id, outfile);
}
while(!infile.eof());
return 0;
}
이 출력 파일
Ф, ью \ XаѓФ에 무엇이다는
일반적으로 초기화되지 않은 변수를 인쇄 할 때 발생합니다. – drescherjm
당신이 옳습니다. 이제 프로그램이 입력 파일에서 새 정보를 가져 오지 않는 이유를 알아야합니다. 도와 주셔서 감사합니다! – Morgan