C Reference
Blog
  • C Reference
  • Overview
    • 🌱Intro
    • 🌻Overview
    • πŸ•’Execution
  • Input-Output
    • βš›οΈData type
    • πŸ”§Expression
    • ✍️Input
    • πŸͺŸOutput
  • Beginner
    • βš–οΈCondition
    • πŸ”Loop
    • πŸŽ’Array
    • πŸ“šString
    • πŸ“¨Function
  • Intermidiate
    • 🏨Structure
    • πŸ“ŒPointer
    • πŸ’ΌFile management
      • putc and getc
      • multiple character
      • fprintf and fscanf
      • Error handling
      • feof and ferror
      • Random access
      • Command line arguments
  • Advanced
    • πŸŽ‘Memory allocation
    • πŸ“½οΈPreprocessor
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Intermidiate
  2. πŸ’ΌFile management

Error handling

Testing a file is available or not,

#include <stdio.h>

int main()
{
    FILE* fp;
    char c[16];

    fp = fopen("file1.txt", "r"); // using write mode
    if (fp == NULL)
        printf("File not found!");
    return 0;
}
Previousfprintf and fscanfNextfeof and ferror

Last updated 1 year ago

Was this helpful?