Thursday, April 12, 2012

Error Checking


#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
const char *FILE_NAME="File.c";
int main ( int argc, char ** argv )
{
int fd=0;
printf ("FINDING %s...\n",FILE_NAME);
fd = open (FILE_NAME,O_RDONLY,0644);
if
(fd<0)
{
perror("Error opening file");
printf("Error opening file:%s\n",strerror( errno ) );
}
else
{
printf("\n File Present");
}
return EXIT_SUCCESS;
}

No comments:

Post a Comment