bouchnina

Afficher les mots d une chaine separer par espace

Jul 12th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h> // On va utiliser des fcts de cette biblio
  3. #define MAX 1000 // supposons qu une phrase contient 1000 character au maximum
  4. void main{
  5. char chaine[MAX];
  6. int i,mots=1;
  7.  
  8. printf("Entrez une chaine : ");
  9. gets(chaine);
  10. printf("Mot %d : ",mots);
  11. for(i=0;i<strlen(chaine);i++){
  12.     if(chaine[i]==' ')
  13.     {
  14.         mots++;
  15.         printf("\nMot %d : ",mots);
  16.         i++;
  17.     }
  18.     printf("%c",chaine[i]);
  19. }
  20.  
  21. system("pause");
  22. }
Advertisement
Add Comment
Please, Sign In to add comment