how to use fopen()?

G

goose

Zygmunt Krynicki said:
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
FILE *file;
file = fopen ("d:/reame.txt", "r");

file = fopen ("d:/readme.txt", "r"); /* :) */
if (file == NULL) {
printf ("f*** it's not working\n");
return EXIT_FAILURE;
}
^^^^^^ <--- no need for that
printf ("finally\n");
fclose (f);
}
^ <--- or that
return EXIT_SUCCESS;
}

I'd say \n is nice if you wish to have portable output,

or even, any output :)
also EXIT_SUCCESS
is far better than guessing some popular value.

and returning a non-success value is better than
*always* returning EXIT_SUCCESS, even on failure.

goose,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top