Hi,

I am working on a small program project and I often need to open files and use memory allocation, like this:

FILE* fastaFile;
if ((fastaFile = fopen(fastaFileName, "w")) == NULL)
{
printf("Error opening file %s.\n", fastaFileName);
printf("ERROR_INVALID_fastaFileName");
}

or

char* theLine;
if ((theLine = (char*)calloc(MAXLINELENGTH, sizeof(char))) == NULL)
{
printf("Error of memory allocation.\n");
printf("ERROR_getEnzyme_theLine\n");
}
theLine[0] = '\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.