Question: n c++, This program takes zero or one command line argument only so, a file is being read using fstream If zero command line arguments

n c++, This program takes zero or one command line argument only so,

a file is being read using fstream

If zero command line arguments are specified, the program should take input from the standard input and print "no command line arguments so, we are taking from standard input"

If one command line argument is specified, the program should use the argument as a file name and take input from that file and print " we are reading from a file that is in the command line"

If the file cannot be opened, the program should print "COULD NOT OPEN", and should then stop.

also when you check the file, check if it is empty, if the file is empty print "file is empty"

If more than one command line argument is specified, the program should print TOO MANY FILENAMES followed by how many files , and should then sto and print how many files it was reading so it the command line has this

file1 file2 file3

the output woul be "TOO MANY FILENAMES 3"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!