Question: Write a program that takes in a filename as a command line argument, opens the file and reads in its contents, and prints out the

Write a program that takes in a filename as a command line argument, opens the file and reads in its contents, and prints out the total number of non-whitespace characters to the screen.
 Write a program that takes in a filename as a command

In this exercise, you are to use an input file stream to read in a text file and output the total number of non-whitespace characters in the file. You can do this by using the stream extraction operator (>>) to read each item in the file to a string variable, and then use the string.length) method to keep a running count of the total number of characters. Criteria Your program should run like this: $ more sampleFile.txt Hello. How are you? $g++ labProgram.cpp $./a.out sampleFile.txt 16

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!