Some of you who were helping me a few days ago might remember this thread:http://cboard.cprogramming.com/showt...999#post181999
Heres a few changes but weird stuff just keeps happening.
Code:
AnsiString TFileHandle::Load() const
{
AnsiString Return;
char *Text;
char Char;
int Length;
int i = 0;
ifstream File(itsName.c_str());
if (File.is_open())
{
File.seekg(0, ios::end);
Length = File.tellg();
File.clear(); /* By using search I read that using this should
solve it, but no matter if I remove it or not the outcome is stil
the same */
File.seekg(0, ios::beg);
Text = new char[Length];
Text[0] = '\0';
while (File.good())
{
File.get(Char);
Text[i++] = Char;
}
Text[i-1] = '\0'; /* I have to do this though it uppose both what
I think and what "The dog" recomended me in the last thread.
Still I have to do it since Text othervise will "have" a sign at the end more then there should be.*/
Return = Text;
delete [] Text;
File.close();
}
return Return;
}
I have found out that Length always is longer then the amount of charectors in the "opened" file. This could be some of the problem, but what worries me more is how come is it longer since Length use a "recomended" method to get the length of the file so why is this method just not working.