Posted: October 26th, 2022

CS programming assignment, programming language C

use Linux!! to write program that count words, lines, characters for multiple files

Assignment 1
Word Count

Don't use plagiarized sources. Get Your Custom Essay on
CS programming assignment, programming language C
Just from $13/Page
Order Essay

General Requirements

• Write a program that counts the number of characters, words, and
lines in a file or group of files

• Subset of the standard Linux “wc” utility

• If no program parameters are specified then process standard input

• If program parameters are specified then they are the names of the
files that are to be processed.

• If more than 1 file is processed then provide a total in addition to the
individual file statistics

Threshold Requirements

• Character, Word, and Line count must match that given by wc for files
that only contain printable characters (text files)

• Works on standard input if no files specified on the command line

• Works on a list of files specified on the command line

• Produce a summary total if more than one file is specified

• Include results that show that the results match wc

• Include results for:
• standard input
• 1 file on command line
• multiple files on the command line

Objective Requirements

• No tabs in the source file

• Proper indentation

• Reasonable names for variables

• Proper submission format

• Produces the same character and line count as wc on binary files
• The word count does not have to match

• The exact definition of a word as used by wc is obscure

How is this Different From “wc”?

• No options on the command line. All parameters are assumed to be
filenames.

• Need not match the results of wc when processing files that contain
non-printing characters.

• Otherwise, it should produce the same results

What is a “word”?

• Sequence of characters delimited by whitespace

• “man isspace” for definition of whitespace

abc123 1 word

a+b-c 1 word

a + b – c 5 words

Example Test

Now is the time

This is the place

2 lines

8 words

34 characters

State Machine for Recognizing Words

Start

Finish

In A
Word

Not In A
Word

is Space

++words

++words

Hints

• The following functions from the standard library may be useful:
fopen

fgetc

isspace

• The following variable is available from the standard library
FILE * stdin;

• Use man to get more information on these functions/variable

Submission

• Printed solution due by the end of class on February 5

• Solution is to include:
• Source Code
• Test Data
• Screen shot of your results

• standard input
• 1 file on command line
• multiple files on the command line

• Screen shot of the same tests run with wc

• One of the tests is the source code for your program. Create at least
one more.

Expert paper writers are just a few clicks away

Place an order in 3 easy steps. Takes less than 5 mins.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00

Order your essay today and save 20% with the discount code Newyr