C++如何读取txt文件,文件比较大想一行一行的读。
2007-08-07 20:16
429 查看
==========================
#include <fstream>
#include <string>
// ..
string filename; // the file name you want to open
string lines; // store the file lines
// ...
ifstream in(filename);
if (in) {
while (getline (in, lines)) // have no '/n',
{
// ;
// store the lines to a vector or list, use method insert
}
// ...
}
else
{
// open file fail....
}
========================= =
ifstream OpenFile("a.txt");
OpenFile.getline(String,"/n",size);
OpenFile.close();
================================
#include <fstream>
#include <string>
// ..
string filename; // the file name you want to open
string lines; // store the file lines
// ...
ifstream in(filename);
if (in) {
while (getline (in, lines)) // have no '/n',
{
// ;
// store the lines to a vector or list, use method insert
}
// ...
}
else
{
// open file fail....
}
========================= =
ifstream OpenFile("a.txt");
OpenFile.getline(String,"/n",size);
OpenFile.close();
================================
相关文章推荐
- 如何利用C/C++逐行读取txt文件中的字符串(可以顺便实现文本文件的复制)
- 如何利用C/C++逐行读取txt文件中的字符串(可以顺便实现文本文件的复制)
- C++如何按行读取txt文件并存储到字符串中?
- 如何利用C/C++逐行读取txt文件中的字符串(可以顺便实现文本文件的复制)
- 如何利用C/C++逐行读取txt文件中的字符串(可以顺便实现文本文件的复制)
- 如何利用C/C++逐行读取txt文件中的字符串(可以顺便实现文本文件的复制)
- 如何利用C/C++逐行读取txt文件中的字符串(可以顺便实现文本文件的复制)
- 求助:C++中读取txt文件如何忽略特定符号后的内容?
- C++读取txt文件的方法
- c++ 读取txt文件
- c语言如何从txt文件读取数据
- C++读取以空格作为数据区分标记,以回车为行标记的txt文件到一个整数数组(字符串妙用)
- c++读取和写入TXT文件的整理
- C++ .TXT文件 数据读取
- 第十五章,读取txt文件(C++)
- C++读取存储float文件(txt文件和二进制文件)
- C++ 利用string读取txt文件的方法
- Adobe脚本之如何读取txt文件的文本内容
- C++中Txt文件读取和写入
- C++中Txt文件读取和写入