Advertisement
NaZaRa

Transformateur min -> maj

Dec 20th, 2012
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. /*
  5.  * Transformateur min -> maj de la première lettre des mots dans une phrase (un mot/2)
  6.  * Utilisez "QUIT" pour forcer la boucle a s'arrêter
  7.  */
  8. int main(void)
  9. {
  10.     char s[100];
  11.     int status=0;
  12.     int loop=100;
  13.     do {
  14.         int i=0;
  15.         printf("Entrez une chaine: ");
  16.         gets(s);
  17.         for (i=0;s[i]!='\0';i++)
  18.         {
  19.             if (strcmp(s, "quit")==0)
  20.             {
  21.                 loop=120;
  22.                 printf("\nPreparing to logout...\n");
  23.                 scanf("%c",s);
  24.                 s[i]='\0';
  25.             }
  26.             else if (s[i]==' ') {
  27.                 i++;
  28.                 if (status==0) {
  29.                     status++;
  30.                     if (97<=s[i]) {
  31.                         s[i]-=32;
  32.                     }
  33.                 }
  34.                 else {
  35.                     status--;
  36.                 }
  37.             }
  38.         }
  39.         if (loop == 100) {
  40.             printf("'s'=%s\n",s);
  41.         }
  42.     } while (loop == 100 && loop != 120);  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement