Original Post
I'm sub-classing from ofstream and have over-ridden the insert operator. Within my class's insert operator I eventually call ofstream::operator<< to write to the file. It works for the integer version, but I can't get it to work for character arrays or for single characters. For character arrays, a hex value is written which I'm reasonably sure is the address of the pointer, and for single chars, the integer value of the char is written to the file.
class MyClass: public ofstream
{
public:
MyClass &operator<<(const char*);
};
MyClass &MyClass::operator<<(const char *string)
{
ofstream::operator<<(' ');
ofstream::operator<<(string);
ofstream::operator<<(1000);
return *this;
}
int main(void)
{
MyClass file;
file.open("test.txt");
file << "test";
file.close();
return 0;
}
test.txt contains: 320x4430091000 How do I modify this to get single characters rather than their integer value and strings rather than the pointer value?