cin.getline()과 getline() 비교
출처 : https://www.cplusplus.com/reference/string/string/getline/?kw=getline
출처 : https://www.cplusplus.com/reference/string/string/getline/?kw=getline
출처 : http://www.tcpschool.com/cpp/cpp_io_streamBuffer 출처 : https://newmkka.tistory.com/78
in Project on Analyze, Project
void account_query::edit_rec()
{
int n;
fstream iofile;
iofile.open("record.bank", ios::in|ios::binary);
if(!iofile)
{
cout<<"\nError in opening! File Not Found!!"<<endl;
return;
}
iofile.seekg(0, ios::end); // 1번 부분
int count = iofile.tellg()/sizeof(*this);
cout<<"\n There are "<<count<<" record in the file";
cout<<"\n Enter Record Number to edit: ";
cin>>n;
iofile.seekg((n-1)*sizeof(*this));
iofile.read(reinterpret_cast<char*>(this), sizeof(*this));
cout<<"Record "<<n<<" has following data"<<endl;
show_data();
iofile.close();
iofile.open("record.bank", ios::out|ios::in|ios::binary); // 2번 부분
iofile.seekp((n-1)*sizeof(*this));
cout<<"\nEnter data to Modify "<<endl;
read_data();
iofile.write(reinterpret_cast<char*>(this), sizeof(*this));
}