Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: I'm looking for a program to count "!" for me.

Author: Pete Galati

Date: 10:55:53 08/23/99

Go up one level in this thread


Thanks Alex, I copied that to the notepad, I'll try it!

Pete

On August 23, 1999 at 04:56:15, Alex Boby wrote:

>On August 22, 1999 at 21:17:01, Pete Galati wrote:
>
>>I'm looking for a program that can count the number of times "!" happens in an
>>opening book that I'm putting together. ! is used at the end of each opening so
>>that would give me a count of the openings.
>>
>>Something that works in Dos or Linux that I can compile to run in Dos.
>>
>>I can't find a way to do it with grep. And there's another Linux utility called
>>"WC" that appears to count the total amount of words, but I havn't figured a way
>>to get it to count that one specific "!" string.
>>
>>Thanks
>>
>>Pete
>
>
>Pete,... give this a try.
>
>/* --------------- BEGIN excount.c --------------------- */
>/* Counts the number of exclamation marks in a text file */
>
>#include <stdio.h>
>
>long countExclamationMarks(FILE *fp)
>  {
>  int nextChar;
>  long count=0;
>
>  while ((nextChar=fgetc(fp))!=EOF)
>    if (nextChar=='!') count++;
>  return count;
>  }
>
>void main(int argc, char *argv[])
>  {
>  char filename[256];
>  FILE *fp;
>
>  if (argc!=2)
>    {
>    printf("Usage: excount [filename]\n");
>    exit(0);
>    }
>  strcpy(filename, argv[1]);
>
>  fp = fopen(filename, "rt");
>  printf("excount: %ld !'s found\n",countExclamationMarks(fp));
>  fclose(fp);
>  }
>
>/* ------------------- END excount.c --------------------- */



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.