I need the coding for the following question in C:
Read from a file (.txt file) and count the number of times the word "a", "is", "the", "and", "that", and "this" occurs.

We provide help, or answers to specific questions..So what have you tried so far? What is your specific question?

One way to do that is to create a structure that contains the strings and an integer

struct words
{
    char* word;
    int count;
};

Now make a simple array of these structures and initialize all counts to 0 and character arrays to the words in the list you posted.

Next, open and read the file one word at a time. fscanf("%s" ...) would be best in this program. For each word read, search the array for it and if found increment the counter.

This sounds like a homework question, I think you need to go through and think what you need to do.

commented: Duh!!! What a worthless first post. -2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.