在线求助linux的readlink函数的使用方法
各位大虾,求助readlink的使用方法,我使用readlink, 每次都返回来一个-1,不知道是哪里出错了,
我的代码是
#include <iostream>
include <unistd.h>
include <dirent.h>
int main()
{
char *path = new char[255];
int count = readlink( "/proc/self/exe ", path , 1023 );
if(count < 0 || count > 1023)
{
cout < < "find root directory failed count = " < < count < < endl;
return 00;
}
path[count] = '\0 ';
cout < < "Path is " < < path < < endl;
return 0;
}
[解决办法]
没环境帮你测试:
1。函数使用对码?
2。有权限访问你设置的路径吗?
3。/ 写的对吗 // \\ \ 哪种我就没法试了