Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started