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
。。。。