Use the global variable errno to do ANSI library error handling. Library routines set errno and it may be tested by user programs. There also are a few functions for error handling:
void assert(int expr);
void perror(const char *msg);
char * strerror(int errno);