I'm trying to read a whole line using scanf multiple times and for some reasons it only works the first time. The second time the loop runs the compiler ignores the scanf function
Here is my code:
#include <stdio.h>
int main()
{
char msg[100];
char to[100];
while (1)
{
printf("[]:Msg to ? :");
scanf("%s", to);
printf("[]:Msg: ");
scanf("%99[^.]", msg);
printf("Sending %s\n", msg);
}
return 0;
}
And this is the output Im given:
[]:Msg to ? :Him []:Msg: Hello mister him!. Sending Hello mister
him! []:Msg to ? :[]:Msg:
And here I was expecting to be able to change the variable to ... Adding a space before %s for some reason has no effect here