Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I would enter code as plain text but it says there is an innappropriate word and does not tell me what it is to fix

I would enter code as plain text but it says there is an innappropriate word and does not tell me what it is to fix it.

Goal: Understanding char, char *, arrays and loops. Reading and writing file

Write a program called countkeywords.c that searches for specific keywords in a file

specified on the command line and prints out the statistics.

You should tackle this problem in stages. Level 0: Get the template and complete fileWriteTester. Keep track of where the file is created on the hard disk since that will be the directory where you will find the file to read. Level 1: Write the body of the function printKeywordStats. Level 2: Write the body of the function countKeywords. This function is responsible for opening the file, reading each line, and for each line checking if any of the keywords appear in that line. If the keywords appear, the array keywordStats is updated. Level 3: Get your program to read the filename from the command line, so you can get the program to analyze different files without having to re-compile it. Level 4: Cleanup your code, remove extra printf statements, test it.

image text in transcribedimage text in transcribed

Untitled-Notepad File Edit Format View Help // writes the numbers 0 to 9 to the given file void fileWriteTester(char filename) printf("writing /I TODO to file %s ", filename); int main(int argc, char argv[]) // write the numbers to 9 to myoutput.txt // Find where this file is on your hard drive // so you can specify the file to read with the full pathname fileWriteTester("myoutput.txt"); char keywords[] "void , "int ", "double , "char ); int keywordStats[] = { 0, 0, 0, 0 }; int keywordLength-4; // TODO: fileToRead so the program gets the file name from argv instead char fileToRead _ "somefile-c"; int err-countKeywords (fileToRead, keywords, keywordStats, keywordLength) if (err -1) printf("Failed to read file: %s ", fileToRead); printf("Press any key to exitin"); char c; scanf("c", &c); return -1; printKeywordStats (keywords, keywordStats, printf("Press any key to exitin"); char c; scanf("%c", &c); return 0; keywordLength); 6:32 PM O Type here to search qx 11/7/2017 ^ Untitled-Notepad File Edit Format View Help // writes the numbers 0 to 9 to the given file void fileWriteTester(char filename) printf("writing /I TODO to file %s ", filename); int main(int argc, char argv[]) // write the numbers to 9 to myoutput.txt // Find where this file is on your hard drive // so you can specify the file to read with the full pathname fileWriteTester("myoutput.txt"); char keywords[] "void , "int ", "double , "char ); int keywordStats[] = { 0, 0, 0, 0 }; int keywordLength-4; // TODO: fileToRead so the program gets the file name from argv instead char fileToRead _ "somefile-c"; int err-countKeywords (fileToRead, keywords, keywordStats, keywordLength) if (err -1) printf("Failed to read file: %s ", fileToRead); printf("Press any key to exitin"); char c; scanf("c", &c); return -1; printKeywordStats (keywords, keywordStats, printf("Press any key to exitin"); char c; scanf("%c", &c); return 0; keywordLength); 6:32 PM O Type here to search qx 11/7/2017 ^

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

Can merger and acquisition create wealth?

Answered: 1 week ago

Question

Explain the steps involved in training programmes.

Answered: 1 week ago

Question

What are the need and importance of training ?

Answered: 1 week ago