txt文件写成dat文件实例

/********************************************************************
    created:    2012/07/09   10:56
    Filename:   SNGData.h
    author:     andeewu
*********************************************************************/
#ifndef _SNGDATA_H__
#define _SNGDATA_H__
#include <vector>
using namespace std;
struct SNList
{
std::string SNGCode; 
};


class SNGData
    {
    public:
        SNGData();
        ~SNGData();



public:
void LoadSNGData(char* fileName);
void WriteSNGData(char* fileName);
        


protected:
std::string GetStringFromChar(char* pStr);
        


    private:
std::vector<SNList> m_vSNG;


    };


#endif


#include "SNGData.h"


SNGData::SNGData()
{


}


SNGData::~SNGData()
{


}




std::string SNGData::GetStringFromChar( char* pStr )
{
std::string str = pStr;
return str;
}


void SNGData::LoadSNGData( char* fileName )
{
FILE*fp = fopen(fileName,"rt");
if(!fp)return;
while (!feof(fp))
{
SNList SNG;
char arrCh[30];
fscanf(fp, "%s\n",arrCh);


  SNG.SNGCode = GetStringFromChar(arrCh);
 
  m_vSNG.push_back(SNG);
}

fclose(fp);


}


void SNGData::WriteSNGData( char* fileName )
{
FILE* fp = fopen(fileName,"wb");
for (int i = 0;i < m_vSNG.size(); i++ )
{   
int iSize = fwrite(m_vSNG[i].SNGCode.c_str(), 17, 1, fp);

}


fclose(fp);
}


// SNG.cpp : Defines the entry point for the console application.
//


#include "stdafx.h"
#include "SNGData.h"


int _tmain(int argc, _TCHAR* argv[])
{
char* filePath[255];
SNGData*  Sng = new SNGData();
Sng->LoadSNGData("E:/Program/SNG/UUID.txt");
Sng->WriteSNGData("E:/Program/SNG/UUID.dat");
if (Sng != NULL)
{
delete Sng;
Sng = NULL;
}
return 0;
}


txt文件格式:

75L6G82HLQS98HK9
GL5W52E75AHRTS7Y
7PG6LPPHGRS7RHMF

。。。。

dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理 dat批处理
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值