8.7.0.3

B — The Very Basics

Due Monday, 12 September 2022, 11:59pm

Purpose to explore the most rudimentary properties of the chosen programming language; to deliver software as specified; and to re-learn to pair-program

Delivery Deposit xcollects in a directory called B in your code repository (master branch).

All auxiliary files must be put into a sub-directory called B/Other/.

You must be able to run this program at the shell command prompt as ./xcollects. But, our test harness will run the program as a sub-process, meaning your shell environment does not exist. In our experience, it is best to deliver a shell script that invokes your program, a compiled executable or an interpretable file.

Task Develop xcollects a program that reads a stream of lines from STDIN and prints a single string on a line by itself to STDOUT.

Each line is supposed to contain a single Acceptable string, which is one of: "┘", "┐", "└", "┌" (and yes, that includes the quotes). The program collects all these strings into a single string, in order, and prints this string on a line by itself when it reaches the end of the input. If any of the input lines do not satisfy this specification, the program prints "unacceptable input" also on a line by itself.

Example Run

    [B] $ ./xcollects

    "┐"

    "└"

    "┌"

    "┘"

    "┐└┌┘"

The last line is the expected output.

The cat command on Linux shows the content of a file. The pipe symbol | redirects STDOUT from the left to the STDIN on the right. This facilitates exploration and gets close to how your program will be tested.

Alternatively try,

    [B] $ cat test1.txt

    "┐"

    "└"

    "┌"

    "┘"

    $ cat test1.txt | ./xcollects

    "┐└┌┘"

at the prompt of a terminal on your Delivery platform.

If a line does not contain a string made up from the acceptable characters, the program prints "unacceptable input" as a string and exits.