Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

CS 320: Lab (C) San Diego State University Exercises 1. (4 points) This program randomly combines words contained in its input stream and sends them to the output stream. At program execution, the...

1 answer below »
CS 320: Lab (C) San Diego State University
Exercises
1. (4 points) 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 ove
ide 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 e
or and suggest co
ective 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 Number of words from input stream to
combine in each crunched output (default =4).
-m The minimum length of each word used
(default =6).
-n 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 educefishersplendidprogram
user@computer: $ ./crunch -s windows omlette lethargic amount
user@computer: $ ./crunch -n 2 -shospitable chicken repair overflow
scrawny belief remain actually
Subtotal:
CS 320: Lab (C) Spring 2019
2. (4 points) Students shall create a program in C which reads ASCII strings from the standard
input until it reaches the EOF symbol. From the accumulated input, the program shall extract
only its unique tokens, seperated by the space character, and send these to the standard output.
For example, if provided with a file containing a text document, it shall send to the standard
output every unique word contained therein. The order the words appear in the output does
not need to be sorted in any particular order.
The program shall insert a space character between each output word and ignore line endings.
Program Name: unique
Command Line Args: none
Program Input: stdin
Program Output: stdout
Return 0 on completion
Allowed Imports: stdio.h
Example Use:
user@computer: $ ./uniqueDelivery
At the start of class on the due date, students shall submit a physical printout of their work to the
class instructor with the pages stapled. The printed package shall include answers to the questions
asked in this prompt, a printout of each source file developed for the assignment, and an example
of any output produced after executing each program with sample input.
Additionally, every student must create a directory in the home directory of their CentOS class
account (provided by the instructor during lecture hours) named ’submission’. Inside this folder,
students shall create a sub-folder named ’lab2’ and store the C files developed for this assignment
there.
+ Linux, unlike Windows, implements a case-sensitive naming
convention. The directories Submission, suBmiSsion, and
submission are unique.
The instructor shall look for the necessary files on edoras at: ~csscXXXX/submission/lab2
Subtotal: Page 2
Answered Same Day Mar 06, 2021

Solution

Pratik answered on Mar 06 2021
159 Votes
#include #include #include int my_atoi(const char *p) {
int k = 0;
while (*p) {
k = (k
3)+(k
1)+(*p)-'0';
p++;
}
return k;
}
void print_help()
{
    printf("Usage Help : \n");
    printf("./crunch [-d 6] [-m 8] [-n 4] [-s]\n");
    printf("-d \n");
    printf("-m \n");
    printf("-n \n");
    printf("-s...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here