catopen()설정하지 않습니다 errno 실패할 경우 어떤 경우에는
-
13-12-2019 - |
문제
catopen 실패 오픈 동양서 파일을 다른 서버에 같은 설정입니다.
을 때 이러한 0 것을 의미 없이 오류가 내에서 이해합니다.
시 말하면 사람이 보았습니다.는 경우 어떤 이유를 알고 왜 그것은 매우 도움이 될 것입니다 나를 위해
샘플 코드가 쓴
int main()
{
nl_catd cat;
string fileName;
cout<<"Enter the cat file name: ";
cin>>fileName;
cat = catopen(fileName.c_str(), 0);
if (cat == (nl_catd)-1)
{
cerr << "Unable to open catalogue: " << fileName <<" ....and the Error number: "<<errno<<"\n";
exit(1);
}
printf("File opened...\n");
catclose( cat );
exit(0);
}
출력한 위 코드
를 위한 성공적인 경우:
./a.out Enter the cat file name: LinkMonitor.epod.cat File opened...
에 대한 faliure 경우:
./a.out Enter the cat file name: ehap_ac_in.epod.cat Unable to open catalogue: ehap_ac_in.epod.cat0
여기서 0 은 오류 코드입니다.
해결책
당신이 삭제 errno
할 때 쓴 문자열 "Unable to open catalogue: "
하기 cerr
.
당신이 값을 저장 errno
습니다.
cat = catopen(fileName.c_str(), 0);
if (cat == (nl_catd)-1)
{
int errno_catopen = errno;
cerr << "Unable to open catalogue: " << fileName <<" ....and the Error number: "<<errno_catopen <<"\n";
exit(errno_catopen);
}
제휴하지 않습니다 StackOverflow