so when i readfile("animal.txt") it gave me
zebra
baboon
orangutan
gorilla
aardvark
lion
tiger
cougar
ocelot
panther
rat
mouse
gerbil
hamster
elephant
rhinoceros
hippopotamus
i would like to know how ist >> s
identify the delimiter and separate the long string into individual words. I provided a txt and my implementation below .
animal.txt
zebrababoonorangutangorillaaardvarkliontigercougarocelotpantherratmousegerbilhamsterelephantrhinoceroshippopotamus
and
SortedList readFile(string infile)
{
SortedList result;
string s;
ifstream ist(infile.c_str()); // open file
// Check if file opened correctly
if(ist.fail()) throw runtime_error("file not found");
// Read file into list
while(ist >> s){
cout<< s << endl;
cout << ist << endl;
result.insert(s);
}
return result;
}