Question: 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

1 Expert Approved Answer
Step: 1 Unlock

Heres an example implementation in C that fulfills the requirements youve mentioned c include void w... View full answer

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 Operating System Questions!