Alright, after reading that I changed the code to make it more compliant (if I understood it properly):
Code:
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
int counter = 0;
void handle_zero(int sig_num){
counter++;
}
int main(){
float num1,num2, num3;
num3 = 1.0/1.0;
signal(SIGFPE,handle_zero);
while (42){
printf("divide: ");
scanf("%f %f", &num1, &num2);
num3 = num1/num2;
printf("result: %f\ncount: %d\n",num3,counter);
}
return 0;
}
But no matter how I enter in the zeros (0.0, 0, 0.00, etc) The counter still outputs 0, when I changed the code to work with integers I think it got caught in an infinite loop (other than the purposeful one) though...if that changes anything :-/