Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program that loops through all of the command line arguments that are passed to the program. For each argument, you are to

Write a C++ program that loops through all of the command line arguments that are passed to the program. For each argument, you are to test to see if there is a file with that name. [you test by attempting to open the file and checking to see if the open was successful]. Your program should do the following

1) If there is NOT a file with the name given in the argument, print, on a single line, the name of the file, a space, and the string FILE NOT FOUND

2) If there is a file with the name given in the argument, print, on a single line, the name of the file, a space, and an integer representing the number of characters in the file. You will note that there should be one line of output for each command line argument that is specified.

Make sure to use the test cases.

If you want to just run one of the test cases, make sure your program is compilesd, then in the Terminal window at the bottom of the screen, type runcase CASENAME where CASENAME is one of the test case names:

none - tests case with no command line arguments

onemissing - tests case with an invalid file name

manymissing - tests case with many invalid file names

onefile - test case with one file manyfiles - test case with many files

mixed - tests with a mix of valid file names and invalid file names

The files are in the directory $ASNLIB/p0 If you want to run your program directly against a given file, you can type prog0 $ASNLIB/p0/peg you can use the UNIX cat command to see the contents of the three actual files, ozy, peg and charl saying cat $ASNLIB/p0/charl will give you the contents of that file

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

Formal SQL Tuning For Oracle Databases Practical Efficiency Efficient Practice

Authors: Leonid Nossov ,Hanno Ernst ,Victor Chupis

1st Edition

3662570564, 978-3662570562

More Books

Students also viewed these Databases questions

Question

Which statement declares intList to be an empty vector

Answered: 1 week ago

Question

1. Identify outcomes (e.g., quality, accidents).

Answered: 1 week ago