Just like the title says, I've been working on a fairly large program and have come upon this bug. I'm also open to alternatives for searching a file for a string instead of using . Here is my code narrowed down:
istreambuf_iterator<char> eof;
ifstream fin;
fin.clear();
fin.open(filename.c_str());
if(fin.good()){
 //I outputted text to a file to make sure opening the file worked, which it does
}
//term was not found.
if(eof == search(istreambuf_iterator<char>(fin), eof, term.begin(), term.end()){
   //PROBLEM: this code always executes even when the string term is in the file.
}
So just to clarify, my program worked correctly in Linux but now that I have it in a win32 app project in vs2010, the application builds just fine but the search function isn't working like it normally did. (What I mean by normal is that the code in the if statement didn't execute because, where as now it always executes.)
NOTE: The file is a .xml file and the string term is simply "administration."
One thing that might or might not be important is to know that filename (filename from the code above) is a XML file I have created in the program myself using the code below. Pretty much I create an identical xml file form the pre-existing one except for it is all lower case and in a new location.
void toLowerFile(string filename, string newloc, string& newfilename){
  //variables
  ifstream fin;
  ofstream fout;
  string temp = "/";
  newfilename = newloc + temp + newfilename;
  //open file to read
  fin.open(filename.c_str());
    //open file to write
    fout.open(newfilename.c_str());
    //loop through and read line, lower case, and write
    while (fin.good()){
      getline (fin,temp);
        //write lower case version
        toLowerString(temp);
        fout << temp << endl;
    }
    //close files
    fout.close();
    fin.close();
}
void toLowerString(string& data){
    std::transform(data.begin(), data.end(), data.begin(), ::tolower);
}
 
     
    