/* A program that prints the number of appearances of a character in  a line */

#include <stdio.h>

int main()
{
  char c, ch = 0;
  int counter = 0;
  printf("Enter a character: ");
  if (scanf("%c", &c) != 1) {
    printf("ERROR: failed to read a character!\n");
    return -1;
  }
  printf("Now enter the text: ");
  flushall();
  while (ch != '\n') {
    scanf("%c", &ch);
    if (ch == c)
      counter++;
  }
  if (counter != 0)
    printf("%c has appeared %d times\n", c, counter);
  else
    printf("%c was not found\n", c);
  return 0;
}
