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


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
Get step-by-step solutions from verified subject matter experts
