I am working on a small program project and I often need to open files and use memory allocation, like this:
if ((fastaFile = fopen(fastaFileName, "w")) == NULL)
printf("Error opening file %s.\n", fastaFileName);
if ((theLine = (char*)calloc(MAXLINELENGTH, sizeof(char))) == NULL)
printf("Error of memory allocation.\n");
theLine = '\0';
The problem is that while the error message will print, it doesn't change the fact that the program crash a few lines later (since a call is made to these values). So the program doesn't quit properly. Is there is a way to print an error message and ask to quit the program, or do I need Windows (or any OS) to tell me the program did something wrong every time?
Thanks for your help.