추출 연산자 (>>)를 사용하여 ifstream 객체를 사용하여 텍스트 파일에서 읽으려고하고 있으며 다음 코드를 수행 할 때 전혀 읽지 않습니다!ifstream을 사용하여 텍스트 파일에서 읽기
#include <iostream>
#include <fstream>
#include <iomanip>
void outputLine(int account, const char *const name , double balance)
{
cout << left << setw(10) << account << setw(13) << name
<< setw(7) << setprecision(2) << right << balance << endl;
} // end function outputLine
int main()
{
ofstream outfile("client.txt",ios::out);
if (!outfile)
{
cout << "the file is not opened .. " << endl ;
exit(1);
}
int account;
char name[30];
double balance;
while (cin >> account >> name >> balance)
{
outfile << account << ends << name << ends << balance << endl ;
cout << "? " ;
}
outfile.close();
ifstream inFile;
inFile.open("client.txt",ios::in);
if (!inFile)
{
cerr << "File could not be opened" << endl;
exit(1);
} // end if
cout << left << setw(10) << "Account" << setw(13)
<< "Name" << "Balance" << endl << fixed << showpoint;
while (inFile >> account >> name >> balance)
{
outputLine(account, name, balance);
}
return 0 ;
}
이 코드에 오류가 있습니까?
'표준 : ends' 문자열 문자 ''의 끝을 삽입하는 마이크로 소프트 고유의 조작이다 \ 0'' 스트림에. 그것은 오래되고 불필요합니다. – 0x499602D2