The Files class doesn't have anything to do with my problem...the difficulties lie with the temp2 variable which is a standard string object. I think the problem has to do with the fact that I used temp2.c_str()....but, I'm not positive. If this was the problem, then I don't know how to rememdy it.
Edit: I did a little bit of switching, etc, and I do not believe the problem is related to the temporary c_str() conversion....
I'll post the entire getData function, along with the Files.h header.
Code:
void getData(vector<char*>& directories, Word& wordStruct)
{
ifstream in;
string temp, temp2;
int i = 0, j = 0;
for (i = 0; i < 3; i++)
{
if (i == 0)
in.open("f1.txt");
if (i == 1)
in.open("f2.txt");
if (i == 2)
in.open("f3.txt");
while(in)
{
getline(in, temp);
for (j = 0; j < temp.size(); j++)
{
if (isalpha(temp[j]))
temp2 = temp2 + temp[j];
else
{
Files files;
files.setWord(temp2.c_str());
wordStruct.addWord(files, i);
temp2 = "";
}
}
}
in.close();
}
}
class Files
{
private:
vector<int> fileList;
char* word;
public:
Files()
{ word = NULL; }
~Files()
{ if (word != NULL) delete word; word = NULL; }
void addFile(int);
char* getWord()
{ return word; }
void setWord(const char*);
void printFile();
};