Modify the program and use the strtok function to count the number of words in the entire book “Robinson Crusoe”. I have already store the book in the file (defoe-robinson-103.txt), Here is the code: #include #include #define MAX 4000 int main(void) { int count = 0; FILE* bkPtr; char buffer[MAX]; fopen_s(&bkPtr, "defoe-robinson-103.txt", "r"); if (bkPtr == NULL) { puts("cannot open the file"); } else { while (fgets(buffer, MAX, bkPtr)) { puts(buffer); } fclose(bkPtr); } }

Question

Hello,

How can I do this :

Modify the program and use the strtok function to count the number of words in the entire book “Robinson Crusoe”.

I have already store the book in the file (defoe-robinson-103.txt),

Here is the code:

#include<stdio.h>
#include<string.h>

#define MAX 4000
int main(void)
{
int count = 0;
FILE* bkPtr;
char buffer[MAX];
fopen_s(&bkPtr, "defoe-robinson-103.txt", "r");
if (bkPtr == NULL)
{
puts("cannot open the file");

}
else
{
while (fgets(buffer, MAX, bkPtr))
{
puts(buffer);
}
fclose(bkPtr);
}

 

}

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: Your soccer team is holding a silent auction dinner as a fundraiser to pay for the team uniforms.  T...

A: Actually, the given information is: A tablet that costs $280 Soccer tickets that cost $100 A gift c...

Q: (a) display_2D1list(list2D) that takes a 2D-list as input and prints all elements of that list in th...

A:   a.) Python program is   #function to display the list def display_2Dlist (list2D):       #when lis...

Q: (a) What are the significant functional dependencies in this relation?         (b) What is/are the c...

A: Functional Dependencies (FD):                It determines the relation between two attributes in da...

Q: Sentiment analysis is a very effective way to enhance and develop your business using the client fee...

A: Sentiment analysis is the process of using natural language processing, text analysis, and statistic...

Q: The three-layer architecture has the primary objective of separating each user’s view of the databas...

A: Click to see the answer

Q: * With comments in the code

A: 1. Algoeithm Step 1 - Construct a Binary Tree with given list of Elements. Step 2 - Transform the...

Q: Write one program that does the following: Ask the user for ten (10) grades, and store the data in ...

A: python code:   import randomdef getGrades(gradesarray,size):    for i in range(size):        n=int(i...

Q: Binary Search algorithm has an element given in sequential arrays.We have seen that at the O (logN) ...

A: Binary Search: Search a sorted array by repeatedly dividing the search interval in half. Begin with ...

Q: Convert the grammar S → aSb bSa a|b into Greibach Normal Form

A: Click to see the answer

Q: Specify the register contents and flag status as the following instructions are executed. A B S Z CY...

A: flag Status TRUE  

Q: JAVA

A: As per our policy, we can answer only one question per question and kindly resubmit the remaining qu...

Q: Q6: (Display patterns using loops) Use nested loops that display the following pattern in three sepa...

A: Pattern A  : Program in  C #include &lt;stdio.h&gt; int main() {    int i, j, rows;    printf("Enter...

Q: Your friend Abiha has just received a computer. A computer carries Ubuntu Linux operating system. Sh...

A: System Software A type of software is the interface between application software and system, is call...

Q: Computer Science Question

A: The, answer has given below:

Q: Write a C program, called msg.c, that reads messages from an input file (or stdin) and verifies whet...

A: Actually, program is a executable software that runs on a computer. 

Q: C++ Student Data Write a program that uses two structures Name and Student to store the following in...

A: Actually, given information about students: Create a nameType structure that consists of First Name...

Q: Evaluate the following statement: DOM is a limited interface which works only on JavaScript and HTML...

A: he HTML DOM model is constructed as a tree of Objects: The HTML DOM Tree of Objects With the obje...

Q: //Using SQL, please make sure your code is working create two tables with one common column example:...

A: The requirement is to create two tables in SQL, the insert atleast 10 records in each table. The que...

Q: code is to be written in C A palindrome is a word that reads the same forward and backwards. For exa...

A: Introduction of the Program: The C program creates char type arrays that stores string and the progr...

Q: Declare a two-dimensional array which can be used to store a yearly budget.Each row of the array cor...

A: Note: Here you didn't mention any programming language so we are creating the program in C++ program...

Q: When removing the string "G" form the following skip list, how many references within this skip list...

A: Deletion In skip list means we have to make connection between predecessor and successor of deleted ...

Q: Program In C  Create one function that contains only one for loop to print the passed array of point...

A: #include &lt;stdio.h&gt; //Function declaration void print(char **arrVal, int size); int main() {   ...

Q: Design an expanding opcode to allow all the following to be encoded in a 32-bit instruction:15 instr...

A: Format 1:

Q: Write a Java application that will accept two filenames (text files) as command line arguments and u...

A: The main objective of the java program is to create two files to read two files by using Threads. On...

Q: Explain the benefits of hierarchial routing in terms of scale and administrative autonomy.Differenti...

A: Note: This question contains the multiple questions. According to the guidelines you will get the an...

Q: Two elements with identical keys should have the same hash code. Group of answer choices True False ...

A: The given question is: Two elements with identical keys should have the same hash code.

Q: Complete the following applied optimization word problem. Include a well-labeled figure, clearly def...

A: Actually, the given information is: To mail a package with the United States Postal service without ...

Q: Find the values to be placed in TCCR1A and TCCR1B if Timer1 should be programmed to operate in CTC m...

A: As we know Timers work by incrementing a counter variable called counter register. The counter regis...

Q: please provide some explanations to help me understand the topic (image).

A: Based on our rule, we should answer only the first question when multiple questions are posted. Plea...

Q: pose java pwork client projects. Most of the projects are on basic java programming. Since you learn...

A: Actually, java is a object oriented programming language. It is a platform independent.

Q: Not sure about the best way to address decimal to binary conversion

A: Click to see the answer

Q: Please answer the question posted and give full explanation of the answer. Please past the successfu...

A: Geometry classpublic static class Geometry {    public static double areaOfCircle(double radius) {  ...

Q: I* Your solution goes here */ while

A: The given is a java code under file named AutoBidder with below functionality:   1. It has a nextBid...

Q: Write a python program that lets the user play the game of Rock, Paper, Scissors against the compute...

A: #Rock, Paper, Scissors Game import random while True: choice=int(input("Enter your choice 1.Rock, 2...

Q: Event Listeners Go to the co_credit.js file in your editor. Create an event listener for the window ...

A: Actually, JavaScript is a programming language for the web.

Q: Write the method catch22(). * * Given an array of ints, return true if the array contains a 2 next t...

A: public boolean catch22(int[] nums) {  boolean isPresent = false;    for(int i = 0; i &lt; nums.lengt...

Q: I am having dificulties answering this from a developers point of view. Can you help me?

A: Solution is in Step 2.