rename()函数出错?无法将文件从一个位置移动到另一个位置。 [英] Error in rename () function?Cant move a file from one location to another.
本文介绍了rename()函数出错?无法将文件从一个位置移动到另一个位置。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用下面的代码将.mdb文件从一个位置移动到另一个位置。但它无法正常工作。
I am using the below code to move a .mdb file from one location to another.But it is not working.
int result;
result= rename(path1.c_str(),path2.c_str());
if (result==0)
{
cout<<"success";
}
else
{
cout<<"failure";
}
推荐答案
从未解答的问题中解决这个问题。
要知道出了什么问题,您必须访问错误代码。使用标准C库函数,如重命名
(另请参阅 http:// www.cplusplus.com/reference/cstdio/rename/ [ ^ ]),错误代码存储在全局变量errno
中,包含 errno.h 时可用。包含该文件时,您还可以调用 strerror() [ ^ ]函数传递代码以获取错误消息字符串。
To get this out of the unanswered questions.
To know what went wrong you must access the error code. With standard C library functions likerename
(see also http://www.cplusplus.com/reference/cstdio/rename/[^]), the error code is stored in the global variableerrno
which is available when including errno.h. When including that file you can also call the strerror()[^] function passing the code to get an error message string.
这篇关于rename()函数出错?无法将文件从一个位置移动到另一个位置。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文