This project is my solution to the Word Count (WC) Challenge posted on codingchallenges.fyi. The challenge required the implementation of a command line utility similar to the Unix wc command. This utility counts the number of characters and lines in a given text file, displaying the count along with the filename.
- Character Count: Counts the number of characters in a specified file.
- Line Count: Counts the number of lines in a specified file.
- C++11 or higher
- A C++ compiler (e.g., g++, clang++)
To count the number of characters in a file:
./ccwc -c <filename>
-c
: Option to count characters.<filename>
: Path to the file you want to analyze.
Example:
./ccwc -c example.txt
To count the number of lines in a file:
./ccwc -l <filename>
-l
: Option to count lines.<filename>
: Path to the file you want to analyze.
Example:
./ccwc -l example.txt
To count the number of characters in a multibyte file:
./ccwc -m <filename>
-m
: Option to count characters.<filename>
: Path to the file you want to analyze.
Example:
./ccwc -c example.txt
- File Not Found: If the specified file cannot be opened, an error message will be displayed.
- Empty File: If the file does not contain any characters or lines, an appropriate message will be shown.
ccwc.cpp
: Contains themain
function and handles command-line arguments.file.cpp
: Contains functions for counting characters and lines.file.h
: Header file with function declarations (make sure to create and include this).
If you would like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes and commit them (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Create a pull request.
For any questions or comments, please reach out to [email protected].
Thank you for using the WC Tool!