C++实现一行一行读取文本的方法
如下所示: #include #include #include int main(int argv,char *arg[]) { fstream f(dictionary.txt);//创建一个fstream文件流对象 vector words; //创建一个vector对象 string line; //保存读入的每一行 while(getline(f,line))//会自动把\n换行符去掉 { words.push_back(line); } //dictionary.tx
下载地址
用户评论