两种方式
# include<sstream>
# include<fstream>
# include<string>
int main()
{
ifstream in("input.txt");
stringstream temp;
temp<<in.rdbuf();
string text = temp.str();//将字符串流转化为字符串
in.close();
}
# include<fstream>
# include<string>
int main()
{
ifstream in("input.txt");
istreambuf_iterator<char> beg(in), end;//利用以字符为元素的流迭代器将文件流中所有的字符
string text(beg, end);//存入到字符串中
in.close();
}