I have the C++ code. It reading file and look for anagrams in this file ("diction").
while (1)
{
infile.getline(buff, sizeof(buff));
if(infile.eof()) break;
sbuff = buff;
sort(sbuff.begin(), sbuff.end());
an.insert(pair<string, string>(sbuff, buff));
}
im = an.begin();
ane = an.end();
vector<multimap<string, string>::iterator> chg;
chg.push_back(im);
while (++im != ane)
{
chg.push_back(im);
if((*im).first != (*chg[0]).first)
{
if(chg.size() > 2)
{
for(unsigned int i=0; i < chg.size() - 1; i++);
cout << endl;
}
chg.clear();
chg.push_back(im);
}
}
if(chg.size() > 1)
for(unsigned int i=0; i < chg.size(); i++)
cout << (*chg[i]).second << endl;
infile.close();
}
After compiling it displays a brunch of empty rows and all. On MacOS on Fedora the same result
What's amiss?