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

What if I use a filename for the first parameter instead of pathname? For example, my program is in the following directory /afs/edu/id/group/a/ftok_test.c

In this case, if I use

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

What is the difference these two?

leppie
  • 115,091
  • 17
  • 196
  • 297

1 Answers1

1

The documentation says:

The application shall ensure that the path argument is the pathname of an existing file that the process is able to stat().

So your second example is ill-formed, because it refers to a directory.

John Zwinck
  • 239,568
  • 38
  • 324
  • 436