#include <iostream>
#include <string>
#include <sstream>
int countOccurrences(const std::string& s, const std::string& word) {
std::istringstream stream(s);
std::string token;
int count = 0;
while (stream >> token) {
if (token == word) {
count++;
}
}
return count;
}
int main() {
std::string s = "c++ c python php c++ c++ php php kotlin c# c++";
std::string word = "c++";
std::cout << "Occurrences of '" << word << "': " << countOccurrences(s, word) << std::endl;
}
/*
run:
Occurrences of 'c++': 4
*/