Look closely at your code, and pay attention to this line:
scanf("%d", answer);
Where is
scanf
supposed to put the value?
Remember, in C all parameters are passed by value, so a copy of the current value of
answer
will be handed to
scanf
- which will assume that it's an address to save the new value in:
C library function - scanf() - Tutorialspoint[
^]
You need to pass an address to
scanf
, not a value!
Try this:
scanf("%d", &answer);