I am building a basic C program that continuously asks users for a string input and prints out the entered input. The program is supposed to exit when a user enters a blank line. However, in my following program, even when I have a conditional that checks whether the user entered a blank line, the program still keeps on going until the user types an input. Below is my code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
char userString[100];
while (1 == 1) {
scanf("%s", userString);
printf("USER ENTERED %s\n", userString);
if (userString[0] == '\n') {
exit(0);
}
}
}