i would never ask for debugging help usually but i am totally lost and have wasted far too much time on this. both peices of code compile correctly. the original function works fine with my program and the second one crashes.
the original code checks a textfile in the root directory of the program. in the textfile, it then checks each line for a substring and returns true if it finds the substring.
bool determinefile(string full, string filename)
{
string file;
file = filename;
ifstream data(file.c_str(), ios::in);
string temp;
while (getline(data, temp))
{
if (determine(temp, full))
{
data.close();
return true;
}
}
data.close();
return false;
}
*
i wanted to change the function to return true, only if the substring is at the start of the line. it appears to work, but my program crashes and i dont know why. it doesnt crash when the function is called, or when it returns, but when the loop it is called from ends. my debugger tells me
First-chance exception at 0x7c812afb in test3.exe: Microsoft C++ exception: std::out_of_range at memory location 0x0012d054..
Unhandled exception at 0x7c812afb in test3.exe: Microsoft C++ exception: std::out_of_range at memory location 0x0012d054..
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
here is the code :
bool determinefile(string full, string filename)
{
string file = filename;
string infilename;
ifstream data(file.c_str(), ios::in);
string temp;
int size = full.size();
int checker = 0;
while (getline(data, temp))
{
for(int counter = 0; counter < size ; counter++)
{
infilename = infilename + temp.at(counter);
}
if (infilename == full)
{
data.close();
return true;
}
infilename = "";
}
data.close();
return false;
}
Im not passing any pointers or references to my function, and i cannot see how it could change any aspect of the function from which it was called. all it does is return true or false. any help would be much appreciated!! thanks