Bonjour,
voila 1er problème
le scanf ne fonctione pas, pourquoi?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 #include<stdio.h> #include<stdlib.h> int combienDeE(char mot[]){ int cpt,i; cpt=0; i=0; while (mot[i]!='\0'){ if ((mot[i]=='e') ||( mot[i]=='E')) cpt++; i++; } return cpt; } int combienDe(char mot[],char x){ int cpt,i; cpt=0; i=0; while (mot[i]!='\0'){ if (mot[i]==x) cpt++; i++; } return cpt; } int main(){ char mot[30]; char x; printf("donnez un mot: "); scanf("%s",mot); printf("le nombre de e est de:%d\n",combienDeE(mot)); printf("donnez un caractére:"); scanf("%c",&x); printf("le nombre de %c est de: %d\n",x,combienDe(mot,x)); return 0; }
second problème d'après ce que j'ai comprit s[]=*s donc pourquoi cela ne fonctionne pas :
quel est la librairie pour utiliser tolower et topper?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 #include<stdio.h> #include<stdlib.h> int combienDeE(char *mot){ int cpt,i; cpt=0; i=0; while (mot[i]!='\0'){ if ((mot[i]=='e') ||( mot[i]=='E')) cpt++; i++; } return cpt; } int combienDe(char *mot,char x){ int cpt,i; cpt=0; i=0; while (mot[i]!='\0'){ if (mot[i]==x) cpt++; i++; } return cpt; } int main(){ char *mot; char x; printf("donnez un mot: "); scanf("%s",mot); printf("le nombre de e est de:%d\n",combienDeE(mot)); printf("donnez un caractére:"); scanf("%c",&x); printf("le nombre de %c est de: %d\n",x,combienDe(mot,x)); return 0; }
merci d'avance pour votre aide !
Partager