手机选中奖号器

源代码在线查看: input.cpp

软件大小: 497 K
上传用户: hndsgzyb
关键词: 手机
下载地址: 免注册下载 普通下载 VIP

相关代码

				// Input.cpp: implementation of the Input class.
				//
				//////////////////////////////////////////////////////////////////////
				
				#include "stdafx.h"
				#include "RandomPhone.h"
				#include "Input.h"
				
				#ifdef _DEBUG
				#undef THIS_FILE
				static char THIS_FILE[]=__FILE__;
				#define new DEBUG_NEW
				#endif
				
				//////////////////////////////////////////////////////////////////////
				// Construction/Destruction
				//////////////////////////////////////////////////////////////////////
				void Input::RemoveAll()
				{
					POSITION pos = m_input.GetHeadPosition();
					while (pos != NULL)
					{
						delete m_input.GetNext(pos);
					}
					m_input.RemoveAll();
				}
				
				Input::Input()
				{
					m_fileformat = 2;
				}
				
				Input::~Input()
				{
				    RemoveAll();
				}
				
				void Input::LoadFromFile(CString path , int fileformat )
				{
				#if 0
					for(unsigned int i = 809300000; i 						m_input.Add(i);
				#else
				    
					////////////////////////////
				    CFile f;
					CString temp;
				
					if( !f.Open( (LPCSTR)path, CFile::modeRead  ) ) 
					{
				        temp.Format("%s文件打开失败!",path);
						AfxMessageBox(temp);
				        return;
					}
				    CArchive ar( &f, CArchive::load);
				
					CInputItem *p;
					BOOL  ret;
				
				    while( (ret = ar.ReadString(temp)) == TRUE )
					{
					  temp.TrimLeft();
					  temp.TrimRight();
				
					  p = new CInputItem;
					  p->city = 0;
					  p->phone = 0;
				
					  if ( fileformat == 1 )
					  {
					      temp = temp.Right(9);
					      sscanf((LPCSTR)temp,"%d", &(p->phone));
					  }
					  else
					  {
						  //temp = temp.Right(9);
						  char c [100],pp[100];
					      sscanf((LPCSTR)temp,"%s\t%s", c,pp);
						  temp = c;
						  temp.TrimLeft();
						  temp.TrimRight();
						  p->city = atol(temp);
				
						  temp = pp;
						  temp.TrimLeft();
						  temp.TrimRight();
				          temp = temp.Right(9);
						  p->phone = atol(temp);
				
					  }
					  m_input.AddTail(p);
					}
				
					m_fileformat = fileformat;
				#endif
				}
							

相关资源