Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A program available on Unix systems (including Macs and Linux machines) called wc returns the number of lines, words, and characters in a file. Write

A program available on Unix systems (including Macs and Linux machines) called wc returns the number of lines, words, and characters in a file. Write a void function called wc() that does what the Unix wc program does. Its single argument should be the name of a file, and it should print the number of lines, words, and characters in the file as well as the file name. You should open and read an entire file and then use various string methods to obtain the requested numbers. An easy way to create the whitespace for the output between numbers is to include tab characters ’t’. The following demonstrates the proper behavior of this function:

wc(’poem.txt’)

10 26 141 poem.txt

write a main() function that prompts the user for a text file name, prints wc as shown below, then calls wc(). Don’t forget to add a call to main(). The proper behavior of the code is shown below:

Enter text file name: poem.txt

honeycrisp> wc poem.txt

10 26 141 poem.txt

Step by Step Solution

3.39 Rating (155 Votes )

There are 3 Steps involved in it

Step: 1

Heres an example implementation in C that fulfills the requirements youve mentioned c include void w... 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

C++ Primer Plus

Authors: Stephen Prata

6th Edition

978-0321776402, 0321776402

More Books

Students also viewed these Operating System questions