سؤال في السي، أرجو الاجابة، غدا عندي امتحان نهائي!!!
اريد ان اكتب برنامج على لغة السي يقوم بقراءة string من المستخدم ثم يقوم البرنامج بطباعة الحرف الأكثر تكرارا مع عدد تكراره، وطباعة الحرف الأقل تكرارا وعدد تكراره.
لقد قمت بكتابة ما يلي، لكنه لا يعمل، ما المشكلة؟؟؟؟
#include <ctype.h>
#include <stdio.h>
#include <conio.h>
void search(char *, char *, char *, int *, int *);
void main () {
int most,least;
char s[100],lst,mst;
clrscr();
printf("Enter a string:\n");
gets(s);
search(s,&lst,&mst,&least,&most);
printf("%c %d - %c %d",lst,least,mst,most);
for(int i=0;i<100;i++) s=' ';
getch();
}
void search(char *s, char *least, char *most, int *least_cnt, int *most_cnt) {
char c=*s, *p=s;
int i=0,j,tmp_cnt;
*least_cnt=0;
*most_cnt=0;
for (i=0;c!='\0';i++) {
tmp_cnt=0;
for (p=s+1;*p!='\0';p++) if (*p==c && !isspace(c)) tmp_cnt++;
if (tmp_cnt < *least_cnt) {
*least_cnt=tmp_cnt;
*least=c;
}
if(tmp_cnt > *most_cnt) {
*most_cnt=tmp_cnt;
*most=c;
}
c=*(s+i+1);
}
}أعينوني أعانكم الله، فغدا عندي امتحان نهائي.