我有一个函数,它通过引用接受struct并填充其中的文件的细节,但是当我编译时,我得到以下错误:
error: no matching function for call to ‘stat::stat(char*&, stat*)’
stat (buffer,&buf);
有人可以让我知道如何将缓冲区传递给stat?
以下是代码:
void filedetails(char *path, int pathlen ,struct stat &buf){
char *buffer;
strncpy(buffer,path,pathlen-1);
buffer[pathlen-1]='\0';
stat (buffer,&buf);
}
它被称为如下:
struct stat st_buf;
char path[256];
//path gets filled here and is manually null terminated//
path[256] = '\0';
filedetails(path,256,st_buf);