Question: Re - code the following portion of main ( ) so that it accepts a single command - line parameter that identifies the external file

Re-code the following portion of main() so that it accepts a single command-line parameter that identifies the external file name of the file being opened, instead of the constant string that's currently being passed in. In addition, add error checking using try/throw/catch to ensure that the user typed exactly two command-line parameters (this includes the program name and the file name). That is, convert the following fragment to use command-line parameters to open a file, with error checking. If there's an error, exit(0);.
int main(){
ifstream infile;
infile.open("scores.txt");

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 Programming Questions!