You are casting away constness and writing to buf anyway. That sounds dangerous, but I don't
know how you are calling Write() [ie, what is the first parameter a pointer to... writable
memory? Is the caller expecting their buffer to change, since the parameter is declared const?]
In all three places, you are passing a const char* to File::Write. (string::c_str() returns a const char*; you
must not change what it points to, and in _tmain(), although you've declared buf to be a char*, because it is a
string literal, it is effectively also a const char*).
const char* means don't write to the string. But your File::Write() function casts away the constness and writes
to it anyway, and this is why you are crashing.
As a general rule, a good design very rarely ever should use const_cast. A proper File::Write() implementation
would make a secondary buffer on the stack and write to it rather than to its (buf) parameter.