Now heres a challenge. I've sort of asked about the same thing before but no one could give me an ansver on how it is so. (PROBLEM: function does not return what it's supposed to.)
The ansver for why I use AnsiString is because it's more "workable" with all those objects which Borland offers. Still I have a pointer to a char since that's what demands as an argument. BTW itsName is private and #include "fstream.h" is in the objects header.Code:AnsiString TFileHandle::Load() const { AnsiString Return; char *Text; int Length; ifstream File(itsName.c_str()); if (File.is_open()) { File.seekg(0, ios::end); Length = File.tellg(); File.seekg(0, ios::beg); Text = new char[Length + 1]; Text[0] = '\0'; File.read(Text, Length); Text[Length + 1] = '\0'; Return = Text; delete [] Text; File.close(); } return Return; }
Now why is it that what thís function return is what's in the file PLUS a few other REAL strange "signs" (with a ShowMessage I have tryed what Text equals just before Return = Text but allso there it have the same odd signs and I kind of expect read to work). Other then that delete [] Text give me an error which doesn't make ANY sence since the AnsiString's operator=(char*) copys what's in the array it doesn't just point at it.
Now can anyone ansver BOTH questions?![]()



LinkBack URL
About LinkBacks





