im trying to do an assignment that deals with planes and repairs.
Im trying to scan in a list of an int with a string, for instance:
1 yes
2 no
3 no
and so on. However, whenever the number -1 is typed, everything has to stop. However, with the code I have now, when -1 is typed, the code still expects a yes or no to come after. How do I solve this so after -1 is typed, everything terminates?
This is my code so far:
int main(int argc, char *argv[]) {
int number = 0;
char YesOrNo[4];
scanf("%d", &number);
while (number != -1) {
scanf(" %s", YesOrNo);
printf("%d %s\n" , number, YesOrNo);
}
return 0;
}
tried to code it with while loops etc