c++ boost 文件读取写入 逗号隔开的字符串

包含: C:\local\boost_1_55_0\

库目录:  C:\local\boost_1_55_0\lib32-msvc-10.0



#pragma comment(lib,"ws2_32.lib")
#include <cstdio>
#include <Winsock2.h>
//add by xia 510 for send socket end
#include <iostream>
#include <opencv2\opencv.hpp>
#include <string>
#include <vector>
#include "eye_tracker.h"
//#include <fstream>
#include <boost/tokenizer.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/program_options.hpp>

using namespace cv;
using namespace std;
using namespace boost; 

//-----------------------------------------------------------------------

int centerx = 450;

int centery = 465;

int rect_w = 200;
int rect_h = 64;

//读取一行并解析
string stringLine;//一行字符串
ifstream infile;
vector<string> tempLine;//空格隔开的数组
infile.open ("C:\\auto\\Eyetrace_centerview\\rect.txt");
//读取一行     
getline(infile,stringLine);
char_separator<char> sep(",");

tokenizer<char_separator<char>> tok(stringLine, sep);
for(tokenizer<char_separator<char>>::iterator beg=tok.begin(); beg!=tok.end(); ++beg)
{             
tempLine.push_back( *beg );


}
centerx = atoi(tempLine[0].c_str());
centery = atoi(tempLine[1].c_str());
rect_w = atoi(tempLine[2].c_str());
        rect_h = atoi(tempLine[3].c_str());
     tempLine.clear();

    infile.close();

//写入一行

ofstream fout( "C:\\auto\\Eyetrace_centerview\\rect.txt");
fout << centerx << ","<< centery << ","<< rect_w << ","<< rect_h<< endl;
fout.close();


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值