Question: Write a C++ program called wcount.cpp that uses the system command wc to count the number of lines, words and bytes in a given text

Write a C++ program called wcount.cpp that uses the system command wc to count

the number of lines, words and bytes in a given text le. Your C++ program should

first request the name of a text le and then invoke the command wc three times. First,

to count the number lines, then to count the number of words and nally to count the

number of bytes in the specied text le. Assume that the specied text file is located

in the same directory as your program.

Example Output

An example of what the program should display, with user input:

user~$ make run

./wcount

Enter file name: device_data.txt

9 device_data.txt

9 device_data.txt

239 device_data.txt

In device_data.txt:

FrontDoor,Closed,1532700000 LivingLight,Off,1532700000 LivingTemp,19,1532700000 LivingTemp,18.5,1532703600 FrontDoor,Open,1532707200 LivingTemp,18,1532707200 LivingLight,On,1532707203 FrontDoor,Closed,1532707205 LivingTemp,18.1,1532710800

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!