What happens if the fopen function fails to open the specified file?

  • The program crashes
  • It returns a NULL pointer
  • It displays an error message on the console
  • It opens a default file
The correct option is b. It returns a NULL pointer. When the fopen() function fails to open the specified file, it returns a NULL pointer, indicating that the file opening was unsuccessful. Programmers can then check for this NULL value to handle errors gracefully.
Add your answer
Loading...

Leave a comment

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