Skip to content

Instantly share code, notes, and snippets.

Created January 17, 2014 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/8472307 to your computer and use it in GitHub Desktop.
Save anonymous/8472307 to your computer and use it in GitHub Desktop.
int read_file (char *filename)
{
FILE *fin;
if ( !(fin = fopen(filename, "r")) )
return -1;
/* ... */
return fclose(fin);
}
int main ()
{
char filename[100];
if ( read_file(filename) )
{
perror("file.dat");
exit(1);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment