catopen 无法以相同的设置在不同的服务器中打开相同的 cat 文件。
当 errno 为 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 输入猫文件名:LinkMonitor.epod.cat 文件打开...
对于故障情况:
./a.out 输入猫文件名:ehap_ac_in.epod.cat 无法打开目录:ehap_ac_in.epod.cat0
这里 0 是错误代码。