我希望这段代码:
IF unsaved packets is greater or = 1,
then
print "There are unsaved packets"
"Would you like to saved them?"
"Type Y for Yes or N for No"
Get user input
IF User input = Y then function save
ELSE IF User input = N then exit
ELSE Return to menue
这是我当前的代码,问题是它根本不会接受输入,如果接受,它不会使用它来确定之后会发生什么。
if(unsavedPackets >= 1)
{
puts("There are currently unsaved packets in the memory");
puts("\nWould you like to save them?");
puts("\nType Y for Yes or N for No");
getch(saveChoice);
printf("%c", saveChoice);
if(saveChoice == "Y")
{
puts("Saving records");
save(recordCount, records);
exit(1);
}
else if(saveChoice == "N")
{
exit(1);
}
else
{
printf("Returning to main menu");
}
}
break;