I am trying to create a program that repeatedly asks the user for input. However, in this case, the program just keeps printing "Enter your input"
until it crashes after I enter something for the first time.
#include <stdio.h>
int main() {
while (1) {
char input[100];
printf("Enter a input: ");
scanf("%[^\n]s", input);
}
}
scanf
, you'll see that it's not reading anything, which could be a good clue."%[^\n]"
instead of"%[^\n]s"
, unless you really want to match a literals
in the input.