0
#include <stdio.h>

int main()
{
    char ch;
    scanf("%c",&ch);
    char s[100];
    gets(s);
    char sen[120];
    gets(sen);
    printf("%c",ch);
    puts(s);
    puts(sen);
}

This is my program to print a character, word, and sentence. But it doesn't take the sentence input and print while I give the word input and gives the output.

Eraklon
  • 4,206
  • 2
  • 13
  • 29
eThan
  • 25
  • 1
  • 2
    Because of the newline left in the buffer by `scanf`. Also please read [Why is the gets function so dangerous that it should not be used?](https://stackoverflow.com/questions/1694036/why-is-the-gets-function-so-dangerous-that-it-should-not-be-used) – Weather Vane Apr 08 '20 at 09:23
  • It is best to stick to one input method. If you mix different ways in the same program you'll create difficulties as they don't work the same way. – Weather Vane Apr 08 '20 at 09:25

0 Answers0