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
#include
//add by xia 510 for send socket end
#include
#include
#include
#include
#include "eye_tracker.h"
//#include
#include
#include
#include

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 tempLine;//空格隔开的数组
infile.open ("C:\\auto\\Eyetrace_centerview\\rect.txt");
//读取一行     
getline(infile,stringLine);
char_separator sep(",");

tokenizer> tok(stringLine, sep);
for(tokenizer>::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();


你可能感兴趣的:(c/c++,文件读取,逗号,字符串)