So I was trying to code a simple number guess game. I've done it in C++, so I decided to try it in C. However, on line 24 (scanf("%i,&reply)), my IDE (Code::Blocks, if that helps) keeps putting out "error: expected expression before % token". What do I do?
//Guessing Game- C
//Take 2
//
#include <stdio.h>
int main() {
//Pose the challenge to the player
printf("Think of any number between 1 and 100. I'll guess it in 7 guesses");
printf(" or less. Reply with \"1\" if the number is lower than the guess,");
printf("\"2\" if the number is greater than the guess, and \"3\" if the");
printf(" guess was correct.\nGot it? OK!\n");
//Set the initial guess to 50
int guess = 50;
//Set the number of guesses to 1
int guesses = 1;
//Create the array of changes that the computer will make
int guessArray[] = {0, 25, 13, 7, 4, 2, 1};
//Create a variable to observe the player's response
int reply;
while (1) {
printf("Is it %i?\n", guess);
scanf(%i, &reply);
if (reply = 1) {
guess = guess + guessArray[guesses];
guesses++;
continue;}
if (reply = 2) {
guess = guess - guessArray[guesses];
guesses++;
continue;}
if (reply = 2) {
guesses++;
break;}
if (reply != 1 && reply != 2 && reply != 3) {
printf("Sorry, but that isn't a valid response.");
continue;}
getchar();
return 0;
}