What is the return type of the `fopen()` function in C?

What is the return type of the fopen() function in C?

a) FILE *
b) int
c) char *
d) void

Answer:

a) FILE *

Explanation:

The fopen() function in C returns a pointer to a FILE object, which is used to control the file being accessed. This FILE * is used in subsequent file operations like fread(), fwrite(), and fclose() to perform operations on the file. If the file cannot be opened, fopen() returns NULL.

Understanding the return type of fopen() is important for managing files correctly and avoiding errors in file handling.

Reference links:

https://www.rameshfadatare.com/learn-c-programming/

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top