我的职能:
//Check Character Case(Upper/Lower Case). If Upper Convert to Lower Case.
char checkLetterCase(char letter){
if(letter >= 65 && letter <= 90){
letter = tolower(letter);
return letter;
}
else if(letter >= 97 && letter <= 122){
return letter;
}
else{
return 0;
}
}
//Add the Specified Letter by Creating a New Node in the Letter List defined
void addLetter(letterListT *letListHead, char letter){
letterListT *newNode;
newNode = (letterListT *)malloc(sizeof(letterListT));
//Check Case(lowe/upper)
letter = checkLetterCase(letter);
//This may only occur on user input
while(letter == 0){
printf("Guess a letter: ");
scanf("%c", &letter);
letter = checkLetterCase(letter);
}
newNode->letter = letter;
newNode->nxt = letListHead->nxt;
letListHead->nxt = newNode;
}
我的主要电话:
addLetter(unusedLetList, i=0);
这是我在跑步时的表现:
Guess a letter: 6
Guess a letter: Guess a letter: t
我的问题是:为什么当我输入一个非字符时,我会收到两次“猜信”消息?