time.h include. Add function error handling