1
저장하고 링크 된 목록을 바이너리로로드하는 함수를 작성하고 있습니다. 함수를로드하려고하면 멈 춥니 다. 프로그램이 충돌하거나 동결하지만이 지점을 넘어 계속되지 않습니다하지 않습니다 표시 :바이너리 읽기 반환 쓰레기
void fLoad(char* fname)
{
fstream fin;
fin.open(fname, fstream::in|fstream::binary);
if(fin.fail())
{
cerr<<"unable to open file";
exit(0);
}
cout<<"File open";
fin.read((char*) &N, sizeof(int));
cout<<N;
system("pause");
for(int i=0;i<N;i++)
{
Clinked* current = new Clinked;
fin.write(current->site_name,sizeof(char)*100);
fin.write((char*) ¤t->cood_x,sizeof(double));
fin.write((char*) ¤t->cood_y,sizeof(double));
fin.write((char*) ¤t->dip,sizeof(double));
fin.write((char*) ¤t->strike,sizeof(double));
//fin.write((char*) current, sizeof(Clinked));
current->next=start;
start=current;
} //at this point it stops
cout<<"\n"<<fname<<" was read succesfully";
fin.close();
cout<<endl;
}
그것은 그 N 중 하나를 터무니없이 큰 아니다; 내가 체크했습니다
-'fstream :: in' 모드 당신이 열하지만'fin.write()'호출
나는 코드를 다음과 같이해야한다고 생각합니다. 그게 당신이 의도 한 것입니까? –