C programming - floating point exception

后端 未结 5 423
生来不讨喜
生来不讨喜 2021-01-03 06:14
matthewmpp@annrogers:~/Programming/C.progs/Personal$ cat prime4.c
/*
 * File:   main.c
 * Author: matthewmpp
 *
 * Created on November 7, 2010, 2:16 PM
 */

#include         


        
5条回答
  •  孤城傲影
    2021-01-03 06:50

    Not sure I believe the answer above!

    X = 5.0; Y = 0.0; Z = X/Y;

    This will give a floating point exception....

    The problem would appear to be that prime_pf is only initialised for 3 elements. So the modulo is attempting to divide by zero. BTW, if you add \n to your printf statement, and add the extra statement fflush(stdout); you are more likely to see the debug output before the program errors.

提交回复
热议问题