Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q2) Write a function that opens a file named text.txt and counts for a character within that file. If the character being searched for is

image text in transcribed
Q2) Write a function that opens a file named text.txt and counts for a character within that file. If the character being searched for is ", then return the number of all the characters in the file. The calculation of the word count, character count, and average word length is done in fle stats.c (which is given to you). Your job is to create a libfs.c and libfs.h. The following function prototype must be used: int find char (const char filename, char thisc); A sample input file text.txt is provided to test your code. The expected output for the sample file is: Number of characters: 118 Number of words: 21 Average word length: 4.4 Hints to understand how the provided file stats.c code works: "Hello world." has 12 characters, 2 words, and 1 period, and an average word length of 5 (measured in charac- ters), but how did you know there were two words? "Helloworld." is 1 word, 11 characters, has 1 period, and has an average word length of 10. What separates words? Can we count the separations instead of the actual words? Can we calculate the average word length by summing all the characters only associated with words? Read the file.stats.c code carefully to find the logic, then write the function int find char to complete the code. Note: In file stats.c we assume there are no double spaces in the input file and the file does not end in a space. The total number of characters includes spaces and punctuation. We also assume there are no linefeeds (1n), and there are only periods for punctuation. The average word length does not include punctuation as part of a word. You only need to submit your libfs.c and libfs.h in your tar. Q3) Use a state machine to copy a file but replace the word "steak" with the word '"chicken. The input fle is named menu.txt, and the output fle is to be named output.txt. In other words

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

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions

Question

=+will appear. Make sure it's portable. Ask yourself:

Answered: 1 week ago

Question

Have roles been defined and assigned?

Answered: 1 week ago