#include <fstream>
ofstream f;
...
f << Convert::ToInt64(textBox1->Text);
std::string ToCppString(String^ s, Text::Encoding^ enc = Text::Encoding::ASCII) {
array<unsigned char>^ chars = enc->GetBytes(s);
pin_ptr<unsigned char> pp = &chars[0];
char *first = (char*)pp, *last = first + chars->Length;
return std::string(first, last);
}