Help us understand the problem. What is going on with this article?

C++でテキストファイル操作だ

テキストファイルを読み込むのはこいつらを使うぞ

#include <fstream>
using namespace std;

ifstream finL("Loutput190831.dat"); //入力
ofstream foutt("testout.dat");    //出力

実際使おう

#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <fstream>
#include <iostream>

using namespace std;


int main()
{

   string str1, str2, str3, str4, str5;
   std::string data;
   int nbin = 256;

   ifstream finL("Loutput.dat");
   ofstream foutt("testout.dat");
   //////
   //Loutput は 01 0000 0001 0002 0003 0004 0005 0006 0007 
   //////
   string buf;
   while (!finL.eof()) //ファイルを最後まで読む
   {
      string uni, bin0, bin1, bin2, bin3, bin4, bin5, bin6, bin7;

      //cout << buf[1] << endl; buf[1] は 1
      finL >> uni >> bin0 >> bin1 >> bin2 >> bin3 >> bin4 >> bin5 >> bin6 >> bin7;
      //       01    0000    0001    0002    0003    0004    0005    0006    0007 
      foutt << bin2 <<bin5
      //       0002   0005   testout.datのなかみ

    finL.close
   }

小話

eofはファイルの一番最後に存在する見えない文字
eofを読んだ時点でfinL.eof()はtrueを返す
なので最後まで読んで欲しい時は

while (!eof.finL){}

となる。

他にも入出力ストリームはstringstreamなどがある。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away