added comments to my c code
added error handling
commented the python code