>>188
「直接」が曖昧

string s;
ofstream f(filename);
f << s;

fwrite(&s, sizeof(string), 1, fp);