Question: Problem statement: Create a C code that MUST use C functions argc, argv, getline, and strstr. That will: Open the file, read the file line

Problem statement:

Create a C code that MUST use C functions argc, argv, getline, and strstr. That will:

Open the file, read the file line by line and search for a substring, Count the number of lines that contain at least one occurrence of the substring, then print the count. Execution should be as follows:

gcc filename.c -o filename

./

then have it print total number of times word was read. SHOULD ONLY COUNT ONE WORD PER LINE.

The goal for this question:

DISCLAIMER****** CODE MUST BE WRITTEN IN C CODE. NOT C++, C#, etc.

To create a program that MUST utilize the functions (argc, argv, char strstr(), and Getline()) to,

1. Open a file

2. Read the file

3. Read txt file line by line

4. count up the number of times a specified word is read(HOWEVER! IT CANNOT COUNT MORE THAN ONE WORD PER LINE!) ex. if the code comes across

a line in a text file that has the word cookie in it 3 times. It can only count the word ONCE since it is counting line by line. Not all the words added up.

5. then display to the user the total number of lines with the specific word.

ex.

gcc -o

./ <"word to be searched">

then execute a total number of times words came up. Again, only count up by one even if there is that specified word multiple times in one line.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!