-1

I'm trying to build a guessing game.

Hi, I'm trying to build a guessing game in C. But when I pass true in while loop in throws the following error:

error: 'true' undeclared (first use in this function); did you mean 'free'?

Screenshot

How can I solve this?

#include<stdio.h>
#include<stdlib.h>

int main()
   {
    srand(time(0));
    int hidden = rand()%100 +1;
    printf("%d\n", hidden);

    while (true){
        int guess;
        scanf("%d", &guess);

        if(guess == hidden){
            printf("You are right");
            break;
        }
        else if(guess > hidden){
            printf("Guess smaller");
        }
        else{
            printf("Guess Larger");
        }
    }

    return 0;
}
ikegami
  • 367,544
  • 15
  • 269
  • 518

1 Answers1

1

true is declared in stdbool.h.

You could also use 1 instead of true.

ikegami
  • 367,544
  • 15
  • 269
  • 518