I tried to run this program, somehow, it runs then after entering an input number.. it stops and says: Segmentation Fault.
I am using a Mac 10.5.8, and used the code::block 10.05 and downloaded the xcode 3.0
When I run the simple "Hello World" program, it runs smoothly. I don't know how to correct this segmentation fault. pls. help..
#include <stdio.h>
main()
{
float gift1, gift2; /*Variables to hold cost. */
float total; /* Variable to hold total amount */
/* Ask for each gift amount */
printf(" How much do you want to spend on your mom? ");
scanf(" %f", &gift1);
printf(" How much do you want to spend on your dad? ");
scanf(" %f", gift2);
total = gift1+gift2; /* Computers total amount spen on gifts */
printf("\nThe total you will be spending on gifts is $%.2f", total);
return 0; /* Ends the program */
}