home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / words.zip / words.c < prev    next >
C/C++ Source or Header  |  1994-06-24  |  1KB  |  42 lines

  1. /* WORDS.C */
  2.  
  3. /* (c) 1994, Matt McLeod */
  4. /* This program is "postcardware".  You can use it as you like, but */
  5. /* please send me a postcard if you continue using WORDS.           */
  6.  
  7. /* This is the main program for WORDS.  It parses the command-line, */
  8. /* and calls word_count() as needed.                                */
  9.  
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14. #include "wcount.h"
  15.  
  16. int main(int argc, char *argv[])
  17. {
  18.     FILE *filein;
  19.     int n = 1, totalwords = 0, words = 0;
  20.     
  21.     _wildcard(&argc, &argv);
  22.     if (argc == 1)
  23.     {
  24.         printf("WORDS 0.1  - (c) 1994 by Matt McLeod\n");
  25.         printf("This program is 'postcardware'.  See WORDS.DOC for info.\n");
  26.         printf("\n");
  27.         printf("Syntax:  words <filename1> <filename2> .. <filenamen>\n");
  28.         return 1;
  29.     };
  30.     while (argv[n]!=NULL)
  31.     {
  32.         filein = fopen(argv[n],"r");
  33.         words = count_words(filein);
  34.         totalwords = totalwords + words;
  35.         printf("%s: %i\n", argv[n], words);
  36.         fclose(filein);
  37.         n++;
  38.     };
  39.     printf("Total wordage: %i", totalwords);
  40.     return 0;
  41. };
  42.