Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project Description I need help writing a C (not C++) console application (in Visual Studio) that determines whether a data stream is sorted in ascending

Project Description I need help writing a C (not C++) console application (in Visual Studio) 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 Your program must handle any length of list (potentially billions!) so your program must work in a 64-bit build. The list will be input (or piped) 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 is sorted by printing the single word 'sorted' on a single line, then return the integer value 101 from 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 Examples issorted issorted data.txt issorted -n issorted --help Streams from the keyboard testing whitespace separated strings. Streams from the file "data.txt" testing whitespace separated strings. Streams from the keyboard testing whitespace unsigned integers. Display the help/usage/copyright information. Notes 1. You are only expected you perform input with getchar() and scanf(). 2. You are not required to validate that every number is actually the correct type (i.e., you don't have to test for the negative sign if reading natural numbers. 3. You should report if the user entered an invalid switch (e.g., -x)

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

How does the virtual assistant support the customers in banking?

Answered: 1 week ago