// Demonstrate glibc 2.2+ feenableexcept #define _GNU_SOURCE #include #include #include #include int main(int argc, char **argv) { if (argc != 3) { fprintf(stderr, "Usage: %s a b # floating-point divide a by b\n", argv[0]); return 1; } feenableexcept(FE_DIVBYZERO); double a = atof(argv[1]), b = atof(argv[2]); printf("%g รท %g = %g\n", a, b, a/b); return 0; }