HELP: Segmentation Fault

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..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  #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 */
 }
scanf expects a memory address. On line 13, you don't give it one.
thanks..
Topic archived. No new replies allowed.