⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hlrcode.cpp

📁 手机选中奖号器
💻 CPP
字号:
// HlrCode.cpp: implementation of the HlrCode class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "RandomPhone.h"
#include "HlrCode.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

HlrCode::HlrCode()
{

}

HlrCode::~HlrCode()
{
    POSITION pos = data.GetHeadPosition();
    while (pos != NULL)
	{
		HlrCodeItem *pdata =  data.GetNext(pos);
        delete pdata;
	}
    data.RemoveAll();
}

void HlrCode::LoadFromFile(const CString &filepath)
{
    HlrCodeItem* pdata = NULL;

    CFile f;

	if( !f.Open( (LPCSTR)filepath, CFile::modeRead  ) ) 
	{
		AfxMessageBox("hlrCode.dat文件打开失败!");
        return;
	}
    CArchive ar( &f, CArchive::load);
	CString temp;

	char l[100],c[100];
	BOOL ret;

    while( (ret = ar.ReadString(temp)) == TRUE )
	{
		pdata = new HlrCodeItem;
		//               longcode,  city
		sscanf((LPCSTR)temp,"%s\t%s", l,c);

		pdata->longCode = l;
		pdata->city = c;
        
		data.AddTail( pdata );
	}
}

void HlrCode::GetHlrCode(const CString &longCode, CString &city, CString &sLongCode)
{
    city = "";
	sLongCode = "";
 
    long i_longcode;
	long i_lc;

    i_longcode = atol( (LPCSTR) longCode );

    POSITION pos = data.GetHeadPosition();
    while (pos != NULL)
	{
		HlrCodeItem *pdata =  data.GetNext(pos);
        i_lc = atol( (LPCSTR) pdata->longCode);

		if (   i_lc == i_longcode )
		{
            city = pdata->city;
			sLongCode = pdata->longCode;
			break;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -