contents   index   previous   next



Clib.strerror()

syntax:

Clib.strerror(errno)

where:

errno - an error number to convert to a descriptive string.

 

return:

string - an error number converted to a descriptive string.

 

description:

When some functions fail to execute properly, they store a number in the .errno property. The number corresponds to the type of error encountered. This method converts the error number to a descriptive string and returns it.

 

see:

Clib.perror()

 

example:

// Opens a file for reading, and if it cannot

// open the file then it prints a descriptive

// message and exits the program.

 

function MustOpen(filename) 

   var fh = fopen(filename, "r"); 

   if ( fh == null ) 

   { 

      Clib.printf("Error:%s\n",

                  Clib.strerror(errno)); 

      Clib.exit(EXIT_FAILURE); 

   }

   return(fh); 

}

 


File I/O