/* priklad pr7_2.c   čítanie a tlač reťazca, počet znakov */
#include <stdio.h>

int charcount(char *s, char c);

void main(void)
{
  char a='a',b,c[80];
  int i=-1;

  printf("Zadaj retazec = ");
  while((c[++i]=getchar()) != '\n');
  c[i]='\0';
  printf("Retazec %s v opacnom poradi :\n",c);
  while(i) putchar(c[i--]);
  printf("\nobsahuje %d vyskytov znaku %c\n", charcount(c,a);
}

int charcount(char *s, char c)
{
  int count=0;

  while(*s!='\0') if(*s++ == c) count++;
  return(count);
}