I have a trie and want to search number of common words in each line of a txt file. I use getline to get the line but unable to proceed.
I tried
string s;
ifstream myfile;
myfile.open("user.txt");
getline(myfile,s);
string person(s);
istringstream iss(person);
do
{
string sub;
iss >> sub;
cout << sub << endl;
} while (iss);
but it says 'std::istringstream iss' has initializer but incomplete type
#include <sstream> // std::istringstream
std::string s;
std::ofstream myfile("user.txt");
std::getline(myfile, s);
std::istringstream iss(s);
std::string sub;
while(iss >> sub)
{
cout << sub << endl;
}
你忘了#include <sstream>
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.