Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int input;
system("clear");
printf("Welcome to Riddles! A game of mystery. Press any key and the enter button to continue.\n");
scanf("%d", &input);
system("clear");
sleep(1);
printf("Riddle 1. At night they come without being told. By day they are gone without being stolen. What are they?\n");
printf("1. goats\n");
printf("2. pillows\n");
printf("3. memories\n");
printf("4. the stars\n");
scanf("%d", input);
if (input == 1)
{
system("clear");
sleep(1);
printf("Correct. The stars is the answer\n");
}
if (input != 1)
{
sleep(1);
system("clear");
printf("Incorrect Game over\n");
}
}
Problem: The output will print :Welcome to Riddles! A game of mystery. Press any key and the enter button to continue" just like it should but when I type in a letter and press enter, this will come up:
Riddle 1. At night they come without being told. By day they are gone without being stolen. What are they? 1. goats 2. pillows 3. memories 4. the stars
Incorrect Game over
The problem is, I couldn't even type an answer. It would skip to the second if statement without accepting any input. Does anyone know what the problem could be?
(p.s. I got this riddle from Lord of the Rings War in the North)