Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genetic Databases

Authors: Martin J. Bishop

1st Edition

0121016250, 978-0121016258

More Books

Students also viewed these Databases questions