C++按行读取文本文件.docxVIP

  • 61
  • 0
  • 约1.89千字
  • 约 3页
  • 2021-11-08 发布于江苏
  • 举报
C++ C++ 按行读取文本文件 分类: C/C++ 2011-05-16 20:31 312人阅读 评论(0) 收藏 举报 很多初学C++ 的同学,对于读取文本文件,并按照行处理数据总是有点不知如何开始,作 为 C++ 的初学者,自己在这里做一点笔记。 其实利用C++ 按行读取文本文件其实很简单。假设有一个文本文件,如下所示: 1 2 3 2 3 4 3 5 7 4 6 8 5 7 9 文件名为split.txt 目的:按照行读取数据,并一个个的显示出来。 代码如下: view plaincopy to clipboardprint? #include #include iostream #include sstream 3.#include fstream 4.#include string 5. 6.int main(int args,char **argv) 7.{ 8. std::ifstream fin(split.txt, std::ios::in); # # i n c l u d e i o s t r e a m # i n c l u d e s s t r e a m # i n c l u d e f s t r e a m # i n c l u d e s t r i n g i n t m a i n ( i n t a r g s

文档评论(0)

1亿VIP精品文档

相关文档