This program randomly combines words contained in its input stream and sends them to the output stream. At program execution, the application shall read in the entire set of words to use during the combination process. After reaching the EOF symbol, the program shall then begin randomly selecting words and combining them into a concatnated output word. By default, the program produces only one combined output word for each execution, but users may change this behavior by providing an optional command line argument (through *argv).

The words the program selects must meet minimum length criteria, and users may also change this value at program execution to meet their needs. The program must accept this.

By default, the program squeezes the words together and omits any spacing between them (e.g., somewhatlikethisbutrandom), but users may override this behavior with a command line argument as well, and the program will produce output with the user specified parameter.

The command line arguments may appear in any order.

When unable to construct strings meeting the minimum length from the input stream, the program shall alert the user to an error and suggest corrective action.

There shall be no duplicate words in any single output combination, but the same word may appear twice in the total output when producing more than one string (i.e. -n specified >1)

Program Name: crunch
Command Line Args:

-d < degree > Number of words from input stream to combine each crunched output (default=4).

-m < size > minimum length of each word used (default=6)

-n < count > Number of output strings to produce (default=1)

-s Indicates to insert a space between the output words (default=none).

Program Input:

stdin

Program Output:

stdout

Return

0 on completion

Allowed Imports:

stdio.h stdlib.h time.h

Example Use:

user@computer: $ ./crunch < dict.txt reducefishersplendidprogram
user@computer: $ ./crunch -s < dict.txt windows omlette lethargic amount
user@computer: $ ./crunch -n 2 -s< dict.txt hospitable chicken repair overflow
scrawny belief remain actually
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.