xxxxxxxxxx
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
int fd = open( path, O_WRONLY | O_CREAT | O_EXCL );
if(fd == -1){
if(errno == EEXIST){
printf("File already exists!\n");
}
else{
printf("Unknown error occurred!\n");
}
}
else{
printf("File created successfully!\n");
}