#define len 100
char sourceString[len];
char command;
int main(void)
{
while (1)
{
printf("\nEnter source: ");
fgets(sourceString, len, stdin); // this gets skipped on second loop.
printf("\nEnter command: ");
scanf(" %c", command)
switch (command)
{
case 'A':
printf("%s", sourceString);
break;
case 'B':
printf("filler");
break;
default:
break;
}
}
return 0;
}
Whether im using fgets or scanf the string always gets skipped on the second loop. I tried adding a space to the second scanf " %c" but it still skips the string input, yes im trying to read a line and then a character.