This sample offers an introduction to the base class library. It shows how to create an application that opens multiple files (specified on the command line) and counts each file's bytes, characters, words, and lines. The results from each file and the total of all files are sent to the console.
The following classes are used by the sample:
clix wordcount [-a] [-o] [-f<output-pathname>] [-c<codepage>] filename
The following table shows the command-line options used by the sample.
| Option | Description |
|---|---|
| -? | Shows usage information. |
| -a | Sorts word usage alphabetically. |
| -c | Specifies the codepage to use to read the file. |
| -f:outfile | Sends output to outfile instead of the console. |
| -o | Sorts word usage by occurrence and then alphabetically. |
The sample source is found in rotor\samples\utilities\wordcount.
The source file is:
The build output location is %TARGETCOMPLUS%\samples\utilities\wordcount. The output file is an executable assembly named wordcount.exe.
All samples are built from the buildall script.
You can also build all the
samples by switching to the root of the sample directory, sscli\samples, and typing
build -c.
You can build this specific sample by switching to the sample directory and typing
build -c.
These steps require that the Shared Source CLI (SSCLI) be already built and functional.
clix wordcount.exe filename
where filename is the name of the file in which to count words and lines.
Copyright (c) 2002 Microsoft Corporation. All rights reserved.