I've got a school assignment to program a simulation of self-checkout machine. To keep it on topic, my problem is with inputting the values of coins/notes.
The way the input is suppossed to work is that you enter it into a single line and end the line with 0, or you can end it by pressing Ctl+d once (specifically said once)
What I've is this:
#inlcude <stdio.h>
void main(){
double number=0, sum=0;
while(scanf("%lf", &number)==1 && number!=0){
//do some stuff with number to check if it's a valid coin
sum+=number;
}
}
It work fine if I end the line with a 0, but if I try to end with Ctrl+d, I have to press it twice. I'm not the only in my class who has this problem, but the teacher says she got it working by using scanf() and the way she has it only needs one Ctrl+d.
Is there a way of doing so?