Can anyone help with this program. Both the functions work fine separately but when for example, I tried to use "if" for simplicity the islower came out as 0 when all the characters were printed out, because it's second in the flow of control. It would also help if I could put this program for counting upper and lowercase into a function with pointers using the function prototype below. I want to be able to return the character that occurs the least but at least once, and the character that occurs the most, taking upper and lowercase separately.
I was redirecting the string from a text file, not sure if that is important.
Thanking you in advance.
void search(char s[], char *p_least, char *p_most, int *p_least_count, int *p_most_cnt);
while ((c = getchar())!=EOF)
if(isupper(c)){
++letter2[c-'A'];}
if(islower(c)){
++letter1[c-'a'];}
#include <stdio.h>
#include <ctype.h>
int main(void)
{
int c,i,j,letter[26],letter2[26];
for(j=0;j<26;++j)
letter2[j]=0;
while ((c = getchar())!=EOF)
if(isupper(c)){
++letter2[c-'A'];}
for(j=0;j<26;++j){
if(j%6 ==0)
printf("\n");{
printf("%2c:%2d", 'A' + j,letter2[j]);
}}
printf("\n\n");
for(i=0;i<26;++i)
letter[i]=0;
while ((c = getchar())!=EOF);
if(islower(c)){
++letter[c-'a'];}
for(i=0;i<26;++i){
if(i%6 ==0)
printf("\n");{
printf("%2c:%2d", 'a' + i,letter[i]);
}}
printf("\n\n");
return 0;
}