-1
key_t ftok(const char *pathname, int proj_id);

如果我对第一个参数使用文件名而不是路径名怎么办?比如我的程序在以下目录 /afs/edu/id/group/a/ftok_test.c

在这种情况下,如果我使用

int key = ftok(/afs/edu/id/group/a/ftok_test.c, 1);
int key = ftok(/afs/edu/id/group/a, 1);

这两者有什么区别?

4

1 回答 1

1

文档说:

应用程序应确保路径参数是进程能够 stat() 的现有文件的路径名。

所以你的第二个例子格式不正确,因为它指的是一个目录。

于 2014-03-27T12:37:56.527 回答