P
Pushkar Pradhan
I'm trying to print out error mesgs. in my program if some call fails.
I want to print the filename and the line no. in which it occurred.
For eg.
x = (float*)malloc(SIZE);
if(x == NULL) {
printf("%s %d: malloc failed.", __FILE__, __LINE__-2);
exit(-1);
}
However, this is a little unsophisticated as I've to calculate whether
it's 2 or 3 lines above the printf.
Is there a better way to do this, i.e. is there some variable or call
which knows where the last call failed?
Pushkar Pradhan
I want to print the filename and the line no. in which it occurred.
For eg.
x = (float*)malloc(SIZE);
if(x == NULL) {
printf("%s %d: malloc failed.", __FILE__, __LINE__-2);
exit(-1);
}
However, this is a little unsophisticated as I've to calculate whether
it's 2 or 3 lines above the printf.
Is there a better way to do this, i.e. is there some variable or call
which knows where the last call failed?
Pushkar Pradhan