How have you defined relPath, and what value does it contain? What is the purpose of the sleep? How do you exit if the file is not F_OK?
Also the above code is missing a closing brace before the while statement.
The following program works fine for me.
Code:
#include <stdio.h>
#include <unistd.h>
#include <string.h>
int main()
{
int fileExists = F_OK;
char relPath[100];
strcpy(relPath,"garbage.txt");
if((fileExists = access(relPath, F_OK)) != F_OK)
{
printf("Can't access file.\n");
return(1);
}
return(0);
}
Jim