The objective of this program is to receive an input file (preferably text file) and convert/count the contents within that file using a specified argument in the command line. The result of the conversion/counting is translated into an output file called output.txt
.
This command line tool is incredibly useful for counting the total amount of words present within the file and converting all text within a text file to uppercase and lowercase.
The command line tool will take arguments that will be passed by the parameters of the program. For example, to convert the content within a given input file to uppercase, then write and display it within an output file, the arguments will look like:
convert –u -i input.txt -o output.txt
In the example shown above, the -u
indicates that the input file content should be converted to uppercase into the output file. Other arguments include the -l
, and -c
.
-l
indicates that the input file should be converted to lowercase-c
indicates counting the words within the input file.
The input file should always be preceded by an -i
to ensure to the program that you’ve entered a filename. The output file declaration follows the same principle, however it is preceded by an -o
.
The program will continue to run if the -i
or -o
arguments are not included for the filenames. If there is no -i
included, the program will prompt the user to enter a text file (from stdin) for conversion. If -o
is not included, then the program will continue to print the results in the stdout.
If specifiers like, -u
, -l
, or -c
are not included in the command line then the program will default the contents of the input file to uppercase.
- Microsoft Syntax: It’s recommended to use the Microsoft compiler as the code comprises of inline assembly that runs on the Microsoft syntax.
- Makefile: A Makefile is a text file that describes how your program should be built (automates the builds). We’re using a Makefile to reduce the time on typing the compile command, and simple mistakes. Makefiles consists of dependencies and rules to produce a successful compilation.