Hey guys, im trying to import an entire file that i have to a single string. Then take that string and search for the parts <td and </td> and with this code it compiles great......but it crashes once the second function is called. I have tested the first function and im pretty sure the other ones work as well. Do you guys see ANY mistakes or have any suggestions as to where i am supposed to go with this? thanks!
==============================================================
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <stdlib.h>
using namespace std;
void getfile(istream & in , string & theFile);
string getTable_entry(const string & theFile, int & pos);
string extractResult(string line);
bool containsUsefulinfo(string entry);
int main()
{
string input;
string filestring;
int pos;
cout << "Give me your input!";
cin >> input;
cout << input<< endl;
getfile(cin,input);
cout << input<<endl;
getTable_entry(input, pos=0);
return 0;
}
void getfile(istream & in , string & theFile)
{
ifstream fin(theFile.c_str());
string filestring;
while(getline(fin, theFile))
{
filestring -+= filestring + theFile;
}
}
string getTable_entry(const string & theFile, int & pos)
{
int x = theFile.find("<td ",pos);
cout << x;
int y = theFile.find("</td>",(x+1));
cout << y;
string z = theFile.substr(x,y);
cout << z;
string m = extractResult(z);
int a = theFile.find("DATE");
int b = theFile.find(" >" ,a+1);
string f = theFile.substr(b+1,b+4);
string c = f + " " + " \t " + " " + m;
pos = (y++);
return c;
}
string extractResult(string line)
{
if(line.find("Saw Shadow"))
{
string y = "Saw Shadow";
return y;
}
else
{
if (line.find("No Shadow"))
{
string y = "No Shadow";
return y;
}
else
{
string y = "Result Unknown";
return y;
}
}
}
bool containsUsefulinfo(string entry)
{
if((entry.find("1") || entry.find("2")) && (isdigit(entry[1])) && (isdigit(entry[2])) && (isdigit(entry[3])))
{
return true;
}
else
{
return false;
}
}
=====================================================================