Answered step by step
Verified Expert Solution
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 nonblank lines, the number of words that contain or less characters, the number of words that contain more than 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 nonwhitespace 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@l numten are valid names, but val, num 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, is an unsigned integer word, while and today are not unsigned integers. Note that a line having only whitespace characters is a nonblank line as well.
How can I use and isdigitisalphaisspaceisalnum 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:
Number of nonblank lines:
Number of Words:
Number of Integers:
Number of Names:
Number of Words Less Than or Equal to Characters:
Number of Words Greater Than Characters:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started