Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C + + program that accepts one command line argument for a file name, and ignores any extra command line arguments that may

Write a C++ program that accepts one command line argument for a file name, and ignores any extra command line arguments that may be provided after the first one. If no file name is provided, the program should print on a new line "NO SPECIFIED INPUT FILE NAME.", and exit. If the file cannot be opened, print on a new line "CANNOT OPEN THE FILE: ", followed by the file name, and exit. The program should read from the file lines until the end of file is found. If the input file is empty, it prints out the message "File is empty." on a new line and then exits.
The program should count the number of lines, the number of non-blank lines, the number of words that contain 5 or less characters, the number of words that contain more than 5 characters, the number of names (special names), and the number of unsigned integers, seen in the file.
A word is defined as a sequence of one or more non-whitespace characters separated by whitespace. A word is defined as a name if it starts by a letter and followed by zero or more letters, digits, underscores _, or @ characters. For example, value, val@l9, num234ten are valid names, but 9val, _num_45 and @num are not. A word is defined as an unsigned integer if it starts by a digit and followed by zero or more digits (ignoring signed integers). For example, 2345 is an unsigned integer word, while 44.75,-345 and 4today45 are not unsigned integers. Note that a line having only whitespace characters is a non-blank line as well.
How can I use and isdigit(),isalpha(),isspace(),isalnum() to check for those factors such as alphabet characters, white space and alphanumeric and so on
How should I use the getline() method to read from the input fileThe displayed output would be as shown below:
Total Number of Lines: 7
Number of non-blank lines: 6
Number of Words: 25
Number of Integers: 5
Number of Names: 8
Number of Words Less Than or Equal to 5 Characters: 18
Number of Words Greater Than 5 Characters: 7
image text in transcribed

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

How to solve maths problems with examples

Answered: 1 week ago

Question

=+What kinds of problems need to be overcome?

Answered: 1 week ago