C++ program to print unique words in a file
Write a function that takes a file name as argument and prints all unique words in it.
We strongly recommend you to minimize your browser and try this yourself first
The idea is to use map in STL to keep track of words already occurred.
(fs >> word)
> :: iterator p = mp.begin();
p != mp.end(); p++)
(p->second == 1)
cout << p->first << endl;
ofstream fs(filename, ios::trunc);
"geeks for geeks quiz code geeks practice for qa"
Thanks to Utkarsh for suggesting above code.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
Attention reader! Don’t stop learning now. Get hold of all the important C++ Foundation and STL concepts with the C++ Foundation and STL courses at a student-friendly price and become industry ready.