#include<stdio.h>
int fcount(char ch, char *a){
if(*a == '\n'){
printf("d");
return 0;
}
else
if(*a == ch){
printf("b");
return 1 + fcount(ch, a++);
}
else
if(*a!=ch){
return fcount(ch, a++);
}
}
int main(){
char *s;
int c = 0, i;
printf("Enter anything you wish\n");
scanf(" %[^\n]s",s);
for(i = 97; i <= 122; i++){
c = fcount(i, s);
if(c != 0)
printf("[%c] %d\n", i, c);
}
}
This is my logic to count the frequency of each character in a given line of text But the program doesnt seem to display the expected output
what I get is this: Segmentation fault(Core dumped) Please offer me some advice!