Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in the list might look like: You cannot make any assumptions about the maximum length for a word, so you must allocate space for each
in the list might look like:
You cannot make any assumptions about the maximum length for a word, so you must allocate space for each word as well as for the node.
A word is a maximal string of digits, letters, and underscores.
When you print your words, print the count in the first spaces then a blank, and then the word. In other words, use the format string d s
Here is an example input and output. Suppose the following is the preamble to the United States Declaration of Independence, and is in the file "declindep":
The unanimous Declaration of the thirteen united States of America,
When in the Course of human events, it becomes necessary for one
people to dissolve the political bands which have connected them
with another, and to assume among the powers of the earth, the
separate and equal station to which the Laws of Nature and of
Nature's God entitle them, a decent respect to the opinions of
mankind requires that they should declare the causes which impel
them to the separation.
Run your program as:
wordsorta declindep
The first lines of your output will be:Write a program that reads words from one or more files named on the command line and prints the words in sorted order use ASCII ordering and a count of how many times each word appears in the input. The easiest way to do this is to use a linked list. A node in the list might look like:
struct node
char word; pointer to word
int count; number of times word occurs
struct node next; pointer to next entry in linked list
You cannot make any assumptions about the maximum length for a word, so you must allocate space for each word as well as for the node.
A word is a maximal string of digits, letters, and underscores.
When you print your words, print the count in the first spaces then a blank, and then the word. In other words, use the format string d s
If your program cannot open a file for reading, print the file name followed by a colon and a space : and then append the system error message. The best way to do this is to use the library function perror
Your program is to return an exit status code that is the number of files named on the command line that could not be opened. So if all files can be opened, the exit status code is ; if five such files cannot be opened, the exit status code would be
Here is an example input and output. Suppose the following is the preamble to the United States Declaration of Independence, and is in the file declindep:
The unanimous Declaration of the thirteen united States of America,
When in the Course of human events, it becomes necessary for one
people to dissolve the political bands which have connected them
with another, and to assume among the powers of the earth, the
separate and equal station to which the Laws of Nature and of
Nature's God entitle them, a decent respect to the opinions of
mankind requires that they should declare the causes which impel
them to the separation.
Run your program as:
wordsorta declindep
The first lines of your output will be:
America
Course
Declaration
God
Laws
Nature
States
The
When
a
among
and
another
assume
bands
becomes
causes
connected
decent
declare
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started