std::ifstream f;の中身を
全部文字列にしたいときってみんなどうしてる?

std::stringstream s;
s << fi.rdbuf();
std::string result(s.str());