In this hands-on example, we will be recreating the popular echo program found on almost all POSIX systems. The echo program takes all of the input provided to the program and echoes it back to stdout. This program is very simple, with the following program options:
- -n: Prevents echo from outputting a newline on exit
- --help: Prints the Help menu
- --version: Prints some version information
There are two other options, -e and -E; we have omitted them here to keep things simple, but, if desired, would serve as a unique exercise for the reader.
To see the full sources for this example, please see the following: https://github.com/PacktPublishing/Hands-On-System-Programming-with-CPP/blob/master/Chapter06/example1.cpp.
The main function presented here is a useful pattern to add to all programs and deviates slightly from the original echo program as exceptions...