ES115 Final C Exam Version 02 Mame Question 01 Explain what

ES115 Final C++ Exam Version 02 Mame: Question 01 Explain what this program segment is doing const char NEWLINE \'In\' const char TAB \'\\t\'; int main. Declare variables. int counter 0; char c; string filename; ifstream filel; Prompt user for file name and open input file. cout Enter the name of the input file \"i cin filename file 1. open (filename c str if (filel fail cerr error opening file file name exit (1) c file 1. get while filel e of switch (c) case break; case break; case NEWLINE: break; case TAB: break. case break; case EOF: break; default if isdigit (c))) counter cout c break; c file 1 get cout endl \"Number of invalid characters is counter endl file 1. close return 0;

Solution


This piece of code opens a file and reads it until the end of file which is conditioned by

while() loop

In switch case statements it checks with the matching c value from loop
and if it gets matcheed value increments the counter ,otherwise it closes the file


and returns o value


Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site