The following code snippet causes the code to bail out prematurely. My question is why my system still shows Program finished with exit code 0.
#include <stdio.h>
int main(void) {
int divisor = 0;
int dividend = 0;
int quotient = 0;
printf("BEGIN\n");
quotient = dividend / divisor;
printf("END\n"); // This statement does not execute
return 0;
}
CodePudding user response:
This is undefined behavior. The compiler is free to do whatever it feels is right in this situation, for example terminating with exit code 0.
