Hey, I want to make a program in which I will find the index of word and count how many words there in a txt file using c++.
You're in luck. https://rosettacode.org/wiki/Word_frequency has this implemented in not only C++ but over 60 other languages.
Given a text file and an integer n, print/display the n most common words in the file (and the number of their occurrences) in decreasing frequency.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.