C program to check file available in a path


PROGRAM:
#include <stdio.h>
#include <unistd.h>
 
int main(void) {
    if( access("/home/pc/test.txt", F_OK) != 0 )
                printf("File not available\n");
        else
                printf("File available\n");
        return 0;
}
OUTPUT:
File not available

2 comments:

  1. what does the "unistd.h" deal with ?

    ReplyDelete
  2. This POSIX header file contains the declarations for functions that perform input/output operations at the operating system level.

    Ref : http://en.wikipedia.org/wiki/Unistd.h

    ReplyDelete