kakalake
March 23rd, 2003, 12:32 PM
Hello!
I try to use the stl::search function but i am not able to figure out the problem. I thing I know how to use this function because i have already used it sucessfully serveral times but now it doesn´t work.
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
using namespace std;
int main()
{
vector<string> vec(1);
vec[0] = "#include";
ifstream ifs( __FILE__ );
istream_iterator<string> is( ifs ), end;
//copy( is, end, ostream_iterator<string>(cout, "\n" ) );
istream_iterator<string> it = search( is, end, vec.begin(), vec.end() );
cout << it->c_str();
return 0;
}
The stl::copy function works fine and outputs me the whole file but the search function doesn´t work.
I tried to debug the function "search" and i saw that in the first loop the iterator "is" has a correct value but in the next loops the iterator "is" keeps always the value of a empty string.
Can somone help me ?
Thanks in advance
I try to use the stl::search function but i am not able to figure out the problem. I thing I know how to use this function because i have already used it sucessfully serveral times but now it doesn´t work.
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
using namespace std;
int main()
{
vector<string> vec(1);
vec[0] = "#include";
ifstream ifs( __FILE__ );
istream_iterator<string> is( ifs ), end;
//copy( is, end, ostream_iterator<string>(cout, "\n" ) );
istream_iterator<string> it = search( is, end, vec.begin(), vec.end() );
cout << it->c_str();
return 0;
}
The stl::copy function works fine and outputs me the whole file but the search function doesn´t work.
I tried to debug the function "search" and i saw that in the first loop the iterator "is" has a correct value but in the next loops the iterator "is" keeps always the value of a empty string.
Can somone help me ?
Thanks in advance