I have difficulty on how to make a program counting word occurences on c/c++ language database. Could anyone help me for this?

I put togeather an example to show you how to read words and compare them with each other, mabey this can get you started.

#include<iostream>
#include<sstream>

using namespace std;

int main() {

	stringstream str("word1 word2 word1 word word1 word2");
	string match = "word2";
	string word;
	int count = 0;
	
	while (str >> word) {
		if (match == word) {
			++count;
		}
	}

	cout << word << ": " << count;

	cin.ignore();
	return 0;
}

>word occurences on c/c++ language database
Can you be more specific about what this "database" is? Is it just a text file, a relational database, or something else?

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.