Hello all,
I have a function that I want to exit gracefully when an "error" occurs in an input file. My function declaration is:
Code:
BSTnode *buildTree(FILE *fp)
The few lines that are causing the problems are:
Code:
if(regcomp(®ex, to_find, REG_EXTENDED | REG_NEWLINE) != 0)
{
fprintf(stderr, "Failed to compile regex '%s'\n", to_find);
return EXIT_FAILURE;
}
I know that if I just use "return" by itself the warning goes away but fails to exit when the error occurs. I also believe this may not be the correct use of stderr. But I need the program to exit when an error has occurred.
Can someone show and explain a better & correct way of doing this?
Thank You.