我对C还是很陌生,所以很抱歉,如果这很简单或已经被回答,我收到的错误消息是“警告:如果(guess ==“ y”){“
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int option;
char guess;
void new_game(){
if (guess == "y") {
if (rand() > 7){
printf("You guessed right!");
}
else{
printf("Wrong! Try again");
}
}
if (guess == "n") {
if (rand() < 7){
printf("You guessed right!");
}
else{
printf("Wrong! Try again");
}
}
else{
printf("Please enter either y or n");
}
}
void main() {
srand(time(NULL));
printf("Welcome To Higher Or Lower, choos an option from below!\n");
printf("Press 1 for a new game\n");
printf("Press 2 to view highscores\n");
printf("Press 3 to quit\n");
printf("Input here --> ");
scanf(" %d", &option);
/*Option 1*/
printf("Do you think the random number will be higher than 7\n");
printf("Enter y for yes or n for no --> ");
scanf(" %c", &guess);
new_game();
}