Dear friends,
I'm using istream_iterator in vc++ after entering the text in the console i dont know how to exit out and get the output. i tried all the ways like cntrl+d etc.. If i'm using cntrl+c it is completely exiting out,with out displaying the output how so solve this problem. The program is
please help in this aspect.
# pragma warning(disable:4786)
# include <iostream>
# include <string>
# include <iterator>
# include <vector>
# include <algorithm>
using namespace std;
bool length_less(string s1,string s2)
{
return s1.size()<s2.size();
}
int main()
{
istream_iterator<string> input(cin),eos;
vector<string> text;
copy(input,eos,back_inserter(text));
string* max=max_element(text.begin(),text.end(),length_less);
cout<<endl<<*max<<endl;
return 0;
}
---------------------------------
Click here to donate to the Hurricane Katrina relief effort. |