This program asks you to sort the letters in an input file and print the sorted letters to an output file (or standard output) which will be the solution. Your program, called codesolve, will take the following command line arguments: % codesolve [-o output_file_name] input_file_name Read the letters in from the input file and convert them to upper case if they are not already in uppercase. If the output_file_name is given with the -o option, the program will output the sorted letters to the given output file; otherwise, the output shall be to standard output.  In addition to parsing and processing the command line arguments, your program needs to do the following: You need to construct a doubly linked list as you read from input. Each node in the list will link to the one in front of it and the one behind it if they exist. They will have NULL for the previous pointer if they are first in the list. They will have NULL for the next pointer if they are last in the list. You can look up doubly linked lists in your Data Structure textbook.  Initially the list is empty. The program reads from the input file one letter at a time and converts it to upper case. Create a node with the letter and 2 pointers to nodes, previous and next. Initially the previous and next pointers should be NULL.  As long as you continue reading letters, if the letter is not already in the list, create a new node and place the node into the list in the proper Alphabetical order. If there is a node in front of it, the previous pointer should point to it. If there is a node after it then the next pointer should point to it. All duplicate letters are ignored. An end of file would indicate the end of input from the input file. Once the program has read all the input, the program then performs a traversal of the doubly linked list first to last to print one letter at a time to the output file or stdout. The output would be all letters on the same line.  Before the program ends, it must reclaim the list! You can do this by going thr

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

This program asks you to sort the letters in an input file and print the sorted letters to an output file (or standard output) which will be the solution. Your program, called codesolve, will take the following command line arguments:

% codesolve [-o output_file_name] input_file_name

Read the letters in from the input file and convert them to upper case if they are not already in uppercase. If the output_file_name is given with the -o option, the program will output the sorted letters to the given output file; otherwise, the output shall be to standard output. 

In addition to parsing and processing the command line arguments, your program needs to do the following:

  1. You need to construct a doubly linked list as you read from input. Each node in the list will link to the one in front of it and the one behind it if they exist. They will have NULL for the previous pointer if they are first in the list. They will have NULL for the next pointer if they are last in the list. You can look up doubly linked lists in your Data Structure textbook. 
  2. Initially the list is empty. The program reads from the input file one letter at a time and converts it to upper case. Create a node with the letter and 2 pointers to nodes, previous and next. Initially the previous and next pointers should be NULL. 
  3. As long as you continue reading letters, if the letter is not already in the list, create a new node and place the node into the list in the proper Alphabetical order. If there is a node in front of it, the previous pointer should point to it. If there is a node after it then the next pointer should point to it. All duplicate letters are ignored.
  4. An end of file would indicate the end of input from the input file.
  5. Once the program has read all the input, the program then performs a traversal of the doubly linked list first to last to print one letter at a time to the output file or stdout. The output would be all letters on the same line. 
  6. Before the program ends, it must reclaim the list! You can do this by going through the list and freeing all nodes. This can be done in either direction. 
  7. It is required that you use getopt for processing the command line and use malloc or calloc and free functions for dynamically allocating and deallocating nodes. 
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY