Error 26. File handle passed to the function is invalid (equal to zero). You have to check if file handle returned by fopen is not equal to zero. If it is zero it means that file could not be opened.

Occurs on attempt to call file write/read/close function on null file handle.

Example (incorrect):

fh =
fopen("nonexistingfile.txt", "r"); // this file does not exist

fputs("Test", fh ); // error here, fh could be null
fclose( fh );  // wrong, fh could be null

Correct usage would look like this:

fh = fopen("nonexistingfile.txt", "r"); // this file does not exist

if( fh ) // correct, call subsequent file read/write/close only when file handle is OK
{
   
fputs("Test", fh );
   
fclose( fh );  
}