CS253: Software Development with C++

Fall 2019

HW 2

CS253 HW2: Command-Line Arguments, More Enemies!

Description

For this assignment, you will improve upon your previous work, adding command-line arguments and line continuation.                 

Arguments

The first command-line argument must be a keyword file. It contains a list of valid keywords, one per line.                 

Any remaining arguments are files containing lists of enemies. If no remaining arguments are given, read enemies from standard input, as in the previous assignment.                 

Sample Runs

Here are sample runs, where % is my prompt. What you type looks like this. Ignore the indentation.                 

    % cat keys
    Name
    bonehead
    RealName
    Motif
    % cat in1
    Name Catwoman
    RealName Selina Kyle
    Motif Cats



    Name Joker
    Motif         Nutty as
     a bag of
        	    squirrels
    % cat in2
    Name Riddler
    RealName E. Nigma
    % cat in3
    Name
        Penguin
    ActualName Oswald Chesterfield Cobblepot
    Motif Birds, umbrellas
    % cmake .
    … cmake output appears here …
    % make
    … make output appears here …
    % ./hw2 keys in1 in2
    Name     Catwoman
    RealName Selina Kyle
    Motif    Cats

    Name  Joker
    Motif Nutty as a bag of squirrels

    Name     Riddler
    RealName E. Nigma
    % cat in2 | ./hw2 keys
    Name     Riddler
    RealName E. Nigma
    % ./hw2 keys in2 in3
    Name     Riddler
    RealName E. Nigma
    ./hw2: file “in3”: key “ActualName” not in keyfile
    %

Input Format

Same as previous assignment, except …                 

A given enemy ends on an empty line, or end of file. That is, an enemy cannot span input files.                 

Lines can now be continued. If a line begins with a space or tab, then it is a continuation of the previous line of the same file. Conceptually, replace the newline of the previous line and the leading spaces or tabs on the next line with a single space.                 

Output Format

Same as previous assignment.                 

Debugging

If you encounter “STACK FRAME LINK OVERFLOW”, then try this:

    export STACK_FRAME_LINK_OVERRIDE=ffff-ad921d60486366258809553a3db49a4a

Requirements

If you have any questions about the requirements, ask. In the real world, your programming tasks will almost always be vague and incompletely specified. Same here.                 

Tar file

    cmake .
    make

How to submit your homework:

    ~cs253/bin/checkin HW2 hw2.tar

How to receive negative points:

Turn in someone else’s work.