Prog mettant en oeuvre les pointeurs.
Bonsoir, j'écris une petit prog dans lequel j'entre une phrase et ou je dois compter le nombre de consonnes et voyelles.
Voilà ce que j'ai fait, mais je coince parce que en fait bah ca compte pas :(
Je commence un peu les pointeurs donc pastappez ;D
Code:
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
| #include <stdlib.h>
#include <stdio.h>
#include <string.h>
void comptage(char tab[], int *pVoy, int *pCons)
{
int i;
for(i=0; i<90; i++)
{
if(tab[i] == 'a' || tab[i] == 'e' || tab[i] == 'i' || tab[i] == 'o' || tab[i] == 'u' || tab[i] == 'y' )
*pVoy++;
else
*pCons++;
}
}
int main(int argc, char *argv[])
{
char tab[90];
int nbVoy = 0, nbCons = 0;
int *pVoy = &nbVoy;
int *pCons = &nbCons;
puts("Entrez une phrase");
fgets(tab, sizeof tab, stdin);
printf("Vous avez entre: ");
puts(tab);
comptage(tab, pVoy, pCons);
printf("Dans votre phrase, il y a %d voyelles\n", *pVoy);
printf("Dans votre phrase, il y a %d consonnes\n", *pCons);
system("pause");
} |
Merci à tous.