Wordcount - a C++ tool project
Description
It's just what it sounds like. A program to count the number of words in a file. Wordcount also counts the number of lines in the file supplied, the number of characters and the number of characters without counting whitespace. It can either output all the counts or just a single one, suitable for pipelining.Raison d'être
A simple reason for this one - Windows XP doesn't appear to have a command line wordcount program! Having spent three years at University using Linux, I got rather used to using the command line along with all of its tools. Being able to count the words in a file is a useful ability, so Wordcount was born.It's also worth nothing that this program was written in C++. I don't really know C++ very well at the time of writing, so this program was something of a learning exercise.
Development Plans
None. The program is finished, as far as I can forsee. It's Wordcount - what else is there to do? Add a mail client??Development History
May 2007 - I wrote a simple program to count the number of words in a file. I think I was working through a website called something like "The C++ Challenge"?January 2008 - I decided to upgrade the program to count more than just words. Having made the program count words, lines and characters (including and not including whitespace) I hit a snag.
25 June 2008 - I remembered that this project needed finishing, so dug out my (neglected) C++ book. Having (re?)discovered how C-Strings work, I was able to process the command line arguments and finish the program.
26 June 2008, 1 am - I decided to write this page rather than go to bed.
System Requirements
Windows XP. The program should work on other systems too. The source code is available, so feel free to compile it for whatever system you want.Downloads
Windows executableSource code (This is a plain text file - you can open it in Notepad)
Instructions
Compiling
- Download the 'wc.cpp' file - the source code.
- Run the source code through your favourite C++ compiler - I used the Borland C++ Compiler, but GCC should also work.
Running
The program is designed to run from the command line. If you have placed the executable in your path variable (You might want to check out my guide about setting your environmental variables.) then you can just type `wc filename' at any command prompt. If you haven't, then you need to use the full path to the executable and/or the file.If you run `wc -h' then a help screen will be displayed. This explains the available options, e.g. only display number of words.
Licence
I don't currently have a specific licence in mind at the moment. However, the conditions I want you to abide by are these:- I am not responsible for anything that goes wrong with your computer, either as a result of using this program or not.
- The program has absolutely no guarantee of quality or anything of the sort. It is provided free of charge for entertainment (or something like that) purposes. You should not use this program on any computer where security, uptime or quality of service are important. If you do, and something goes wrong, then you agree to acknowledge that the program was not my fault in any way, and in fact was your fault for messing around on important machines.
- You are welcome to distribute this program as much as you want, as long a) as you do so without charge, and b) You do not remove any references to me as the creator.
In other words, please feel free to give it to your friends, don't take money in exchange for it and don't claim that it's your work. - If you want to alter the program, feel free. If you want to share your alterations with other people, then you may do so as long as a) you don't charge for them, and b) you don't remove any references to me as the original creator.
In other words, the source code is available for you to use - please use it if you want to! If you create something nice, then share nicely and don't make other people pay for it. Also, don't claim that it's entirely your work if it isn't.