c language check if the file exists

www.lau‮oc.irutt‬m
c language check if the file exists
//  check if file exists
#include <stdio.h>
#include <stdlib.h>
#include<unistd.h> // define F_OK 

void fileCheck(const char *fileName);

int main (void) {
    char *fileName = "test.txt";

    fileCheck(fileName);
    return 0;
}

void fileCheck(const char *fileName){

    if(!access(fileName, F_OK )){
        printf("The File %s\t was Found\n",fileName);
    }else{
        printf("The File %s\t not Found\n",fileName);
    }

    if(!access(fileName, R_OK )){
        printf("The File %s\t can be read\n",fileName);
    }else{
        printf("The File %s\t cannot be read\n",fileName);
    }

    if(!access( fileName, W_OK )){
        printf("The File %s\t it can be Edited\n",fileName);
    }else{
        printf("The File %s\t it cannot be Edited\n",fileName);
    }

    if(!access( fileName, X_OK )){
        printf("The File %s\t is an Executable\n",fileName);
    }else{
        printf("The File %s\t is not an Executable\n",fileName);
    }
}

result:

The File test.txt        not Found
The File test.txt        cannot be read
The File test.txt        it cannot be Edited
The File test.txt        is not an Executable

Process returned 0 (0x0)   execution time : 0.297 s
Press any key to continue.
Created Time:2017-08-28 10:00:04  Author:lautturi