The code is:
#include <stdio.h>
#include <string.h>
int main (void)
{
char ch,str[100],sen[100];
printf("enter the string : ");
fgets(str,sizeof(str),stdin);
printf("enter the character : ");
scanf("%c",&ch);
printf("enter the sentence : ");
fgets(sen,sizeof(sen),stdin);
printf("character is : %c\n",ch);
printf("string is : %s\n",str);
printf("sentence is : %s",sen);
return 0;
}
this is how i expect my programm to work: input:
enter the string : abcde
enter the character : k
enter the sentence : i am a beginner.
output:
character is : k
string is : abcde
sentence is : i am a beginner.
this is what it results in :
enter the string : abcde
enter the character : k
enter the sentence : character is : k
string is : abcde
sentence is :
This program is not prompting the user to input sentence.
Please tell me why this fgets()
function is not working properly.