Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C console application that determines whether a data stream is sorted in ascending order. A data stream can be either keyboard or a

Write a C console application that determines whether a data stream is sorted in ascending order. A data stream can be either keyboard or a file. The interface for the program is a command shell's command line.

Requirements

The program must handle any length of list so your program must work in a 64-bit build. The list will be input from the console or read from a file. This is terminated with end-of-stream ^Z on windows.

The output must indicate if the data sorted by printing the single word 'sorted' on a single line, then return the integer value 101 from the main. if the stream is not sorted, you are to print "element # (Value) not sorted where # is the offset of the first out-of-order element and value is the value of the unsorted element. In the unsorted case, main must return the integer 100.

Failure to complete the test (bad input, filename, switch) for any reason and the main should return; EXIT_FAILURE

If help was selected, main should return EXIT_SUCCESS.

The command line arguments below.

image text in transcribedThat is what it should look like if the user enters -help or --help.

image text in transcribed

Note

1. Expected you perform input with getchar() and scanf().

2. Not required to validate that every number test for the negative sign if reading natural numbers.

3. Should report if the user entered an invalid switch (e.g., -x)

The green, blue and yellow items are necessary requirements, but the red items below can not be included.

image text in transcribed

D: lusr>issorted n 112345 Z nZ nZ sorted D: \usr>issorted n 11 2343 element 6 (3) not sorted D: \usr> \begin{tabular}{ll} \hline Implements: issorted -h & \\ Implements: issorted --help & \\ Implements: issorted -n & (from keyboard) \\ Implements: issorted -i & (from keyboard) \\ Implements: issorted -- & (from keyboard) \\ \hline Implements: issorted -s & (from keyboard) \\ Implements: issorted -1 & (from keyboard) \\ \hline \end{tabular} Output is correctly formatted - When sorted - When not sorted - Error conditions Exit codes are correct - When sorted - When not sorted - For 'help' - For errors File input - Reads from file - Reports file errors Non-functional requirements Uses a multi-file solution Handles any size of input word/line (strings are fully dynamic) Uses the same string functions for processing s and 1 Checks for memory leaks \begin{tabular}{|l} Recycles dynamic memory for string and line input \\ \hline tas a memor lek \end{tabular} Has a memory leak Store the entire stream/file in memory

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions

Question

Write the difference between sexual and asexual reproduction.

Answered: 1 week ago

Question

What your favourite topic in mathematics?

Answered: 1 week ago

Question

Briefly describe vegetative reproduction in plants.

Answered: 1 week ago

Question

=+What kinds of problems need to be overcome?

Answered: 1 week ago