Many functions return some sort of error/success value that can be checked for success or failure. Those functions that return a regular value, can be checked, again if the value indicates success or failure.
Check the man page for the Standard Library functions to see what they return, and other information regarding error checking.
Your own functions could be written to return some value that can be checked.
You can also use the assert macro, to abort the program if some condition fails.
There are many articles that expand on this topic.