You're writing a C program that needs to read from a file and display the content on the screen. How would you handle the situation if the file does not exist?

  • Create an empty file
  • Ignore and continue
  • Print an error message and exit
  • Prompt user for a new file name
Printing an error message and exiting the program is a common approach when a required file is not found. It informs the user about the issue and halts the program execution to prevent further errors.
Add your answer
Loading...

Leave a comment

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