#include #include // Correction de l'exercice 1 de l'interrogation n°1 //-------------------------------------------------- int main() { printf("Tapez votre chaine : \n"); char *chaine; chaine=(char*) malloc(80*sizeof(char)); // lecture de la chaine int i=0; scanf("%c", chaine); while(chaine[i]!='\n') { i++; scanf("%c", chaine+i); } // sauter les premiers espaces i=0; int compt=0; //sauter les premiers espaces while ((chaine[i]==' ')&&(chaine[i]!='\n')) i++; if ((chaine[i]!='\n')&&(chaine[i]!='.')) compt++; // boucle: avancer jusqu'à l'espace, compter le mot, sauter les espaces do { while ((chaine[i]!=' ')&&(chaine[i]!='\n')) i++; if(chaine[i]!='\n') { //Avancer vers le mot en sautant les espaces while ((chaine[i]==' ')&&(chaine[i]!='\n')) i++; if ((chaine[i]!='\n') &&(chaine[i]!='.')) compt++; } } while (chaine[i]!='\n'); printf("Nombre de mots = %d",compt); return 0; }