C++ 读取文件内容赋值给变量

#include ifstream
ifstream file;
file.open("abc.txt",ios::in);
string str1,str2;
file>>str1;//将读入的第一个字符串赋值给str1,按照空格来识别不同的字符。

你可能感兴趣的:(C++ 读取文件内容赋值给变量)