Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

The output should be the exact as shown in the example and it should print out the exact same messages if the file is empty.

The output should be the exact as shown in the example and it should print out the exact same messages if the file is empty. image text in transcribedimage text in transcribed

Write a C++ program that reads from a file name specified in the command line as an argument, and ignores any extra command line arguments that are provided after the file name. However, if no file name is provided, the program should use the standard input instead of a file. If the file cannot be opened, print on a new line "File cannot be opened: ", followed the file name, and exit. The program should read from the file character by character until the end of file. If the input file is empty, print out the message "File is empty." on a new line and then exit. The program should count the number of lines, number of words, number of characters, number of digit characters (O' - 9'), and the number of alphabetic characters seen in the file. For example, with an input file of the following contents: 3456 Georgre 1234 smith 4321 staci 278 sandra 10.25 4.5 12.75 25.35 The displayed output is as shown below: LINES: 4 WORDS: 12 CHARS: 75 DIGITS: 29 LETTERS: 21 3456 Georgre 10.25 1234 smith 4.5 4321 staci 12.75 278 sandra 25.35

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_2

Step: 3

blur-text-image_3

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

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students explore these related Databases questions

Question

What your favourite topic in mathematics?

Answered: 3 weeks ago

Question

4. What decision would you make and why?

Answered: 3 weeks ago