I just started learning on C, I was trying to do some exercises. There is an exercise that wants me to take input for a character,a word and a sentence then print it. I tried to take all three input with scanf but when I execute the code program wants the first two inputs but skips the third input and prints the first two. I tried fgets and gets functions too but I couldn't solve the problem.
#include <stdio.h>
#include <string.h>
int main()
{
char ch;
char s[100];
char sen[100];
scanf("%c", &ch);
scanf("%s", &s);
scanf("%[^\n]%*c",sen);
printf("%c", ch);
printf("\n%s", s);
printf("\n%s", sen);
return 0;
}
I tried scanf, fgets and gets to enter all the inputs but I couldn't take and print all of them.