Florida State College at Jacksonville Standard Input Programming Project

Description

This assignment asks you to sort the words in an input file (or from standard input) and print the sorted words to an output file (or standard output). Your program, called doublesort, will take the following command line arguments:% doublesort [-cd] [-o output_file_name] [input_file_name]If -c is present, the program needs to compare the strings case sensitive. Otherwise, the program compares strings case insensitive. If the output_file_name is given with the -o option, the program will output the sorted words to the given output file; otherwise, the output shall be to standard output. Similarly, if the input_file_name is given, the program will read from the input file; otherwise, the input will be from the standard input. If the -d is present, the output will be in lexicographically descending order otherwise it will be in lexicographically ascending order. You must use getopt() to parse the command line arguments to determine the cases and the order. 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 on the web or in your Data Structure textbook. Initially the list is empty. The program reads from the input file (or stdin) one word at a time; If the -c is present you would use the words as they are read in. If there is no -c then do the comparison case insensitive where all capital letters are the same as all lower case letters. Use capital letters to store the words and print them out.As long as you continue reading words, if the word is not already in the list, it should create a list node that stores a pointer to the word and then insert the list node into its place in the list. If the word exists, then do not create a node. All duplicate words are ignored.An empty line would indicate the end of input for stdin, an end of file would indicate the end of input for an input file.You must develop a string comparison function. You must not use the strcmp() and strcasecmp() functions provided by the C library. You must implement your own version. You will be comparing the ASCII values. Note that using ASCII, all capital letters come before all lower case letters.Once the program has read all the input (when EOF is returned or a blank line encountered), the program then performs a traversal of the doubly linked list either first to last as the default or if the -d option is present, last to first to print out all the strings one word at a time to the output file or stdout. The output would be one word per line. 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. Make sure you also reclaim the memory occupied by the string as well.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 and the buffers for the strings. It is required that you implement your own string comparison function instead of using the corresponding libc functions.Here’s are some examples:[email protected]:~ 105% cat infile1
apple
apple
APPLE
APPLE
Apple
banana
BANANA
[email protected]:~ 107% doublesort infile1
APPLE
BANANA
[email protected]:~ 108% doublesort -c -o outfile1 infile1
[email protected]:~ 109% cat outfile1
APPLE
Apple
BANANA
apple
banana
[email protected]:~ 110%
[email protected]:~ 108% doublesort -d -c -o outfile1 infile1
[email protected]:~ 109% cat outfile1
banana
apple
BANANA
Apple
APPLE
[email protected]:~ 110%
Please submit as one zip file. Submit the source code and the Makefile in the zip file. One should be able to create the executable by simply ‘make’. The Makefile should also contain a ‘clean’ target for cleaning up the directory (removing all object files at a minimum). Make sure you don’t include intermediate files: *.o, executables, *~, etc., in your submission.

Tags:
computer science

programming language

standard input

User generated content is uploaded by users for the purposes of learning and should be used following Studypool’s honor code & terms of service.

Reviews, comments, and love from our customers and community:

Article Writing

Keep doing what you do, I am really impressed by the work done.

Alexender

Researcher

PowerPoint Presentation

I am speechless…WoW! Thank you so much!

Stacy V.

Part-time student

Dissertation & Thesis

This was a very well-written paper. Great work fast.

M.H.H. Tony

Student

Annotated Bibliography

I love working with this company. You always go above and beyond and exceed my expectations every time.

Francisca N.

Student

Book Report / Review

I received my order wayyyyyyy sooner than I expected. Couldn’t ask for more.

Mary J.

Student

Essay (Any Type)

On time, perfect paper

Prof. Kate (Ph.D)

Student

Case Study

Awesome! Great papers, and early!

Kaylin Green

Student

Proofreading & Editing

Thank you Dr. Rebecca for editing my essays! She completed my task literally in 3 hours. For sure will work with her again, she is great and follows all instructions

Rebecca L.

Researcher

Critical Thinking / Review

Extremely thorough summary, understanding and examples found for social science readings, with edits made as needed and on time. Transparent

Arnold W.

Customer

Coursework

Perfect!

Joshua W.

Student

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>