home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_09_12 / 9n12123b < prev    next >
Text File  |  1991-09-24  |  1KB  |  54 lines

  1.  
  2. Listing 6
  3. ***********
  4.  
  5. #include <ctype.h>
  6. #include <string.h>
  7.  
  8. int ind=1,tmp=1;
  9. int mat=1,spc;
  10.  
  11. main()
  12. {
  13.         char text[1024];
  14.  
  15.         getln(text);
  16.         putln(text);
  17.         printf ("Sentence is %d\n",ind);
  18.         printf ("And has %d spaces in it\n",spc);
  19. }
  20. getln(text)
  21. char *text;
  22. {
  23.         printf ("Enter Text : ");
  24.         while((text[ind-1]=getchar())!='\n')
  25.         {
  26.                 ind++;
  27.         }
  28. }
  29.  
  30. putln(text)
  31. char *text;
  32. {
  33.         printf ("Text is    : ");
  34.  
  35.         while(text[tmp-1]!='\n')
  36.         {
  37.                 if (mat==1)
  38.                 {
  39.                         printf("%c",toupper(text[tmp-1]));
  40.                         mat=0;
  41.                 }else{
  42.                         printf("%c",tolower(text[tmp-1]));
  43.                 }
  44.                 if (isspace(text[tmp-1])) {
  45.                         mat=1;
  46.                         spc++;}
  47.                 if (text[tmp-1]=='.' || text[tmp-1]==',') mat=1;
  48.                 tmp++;
  49.         }
  50.         printf("\n");
  51. }
  52. *********
  53.  
  54.