#include<iostream>
#include<hash_map>
using namespace std;
using namespace stdext;

struct GameCharacter
{
 GameCharacter(){}
 GameCharacter(int CharCd, int Level, int Money)
 {
  _CharCd = CharCd;
  _Level = Level;
  _Money = Money;
 }
 int _CharCd; //캐릭터 코드
 int _Level;  // 레벨
 int _Money;  // 돈
};

void main()
{
 hash_map<int, GameCharacter> Characters;

 GameCharacter Character1(12, 7, 1000);
 Characters.insert(hash_map<int, GameCharacter>::value_type(12, Character1));

 GameCharacter Character2(13, 4, 4000);
 Characters.insert(hash_map<int, GameCharacter>::value_type(13, Character2));

 GameCharacter Character3(14, 5, 3000);
 Characters.insert(hash_map<int, GameCharacter>::value_type(14, Character3));

 hash_map<int, GameCharacter>::iterator Iter1;
 for (Iter1 = Characters.begin(); Iter1 != Characters.end(); ++Iter1)
 {
  cout << "캐릭터 코드 : " << Iter1->second._CharCd << "레벨 : " << Iter1->second._Level << "가진 돈" << Iter1->second._Money << endl;
 }
 cout << endl;

 hash_map<int, GameCharacter>::reverse_iterator RIter;
 for (RIter = Characters.rbegin(); RIter != Characters.rend(); ++RIter){
  cout << "캐릭터 코드 : " << RIter->second._CharCd << "레벨" << RIter->second._Level << "가진 돈" << RIter->second._Money << endl;
 }
 cout << endl << endl;

 //Characters에 저장한 요소 수
 int CharacterCount = Characters.size();

 //검색 캐릭터 코드 14 찾기
 hash_map<int, GameCharacter>::iterator FindIter = Characters.find(14);

 if (Characters.end() == FindIter)
 {
  cout << "캐릭터 코드가 20인 캐릭터가 없습니다" << endl;
 }
 else
 {
  cout << "캐릭터 코드가 14인 캐릭터를 찾았습니다." << endl;
  cout << "캐릭터 코드: " << FindIter->second._CharCd << "레벨" << FindIter->second._Level << "돈" << FindIter->second._Money << endl;
 }
 cout << endl;

 //15 삭제
 Characters.erase(13);
 for (Iter1 = Characters.begin();  Iter1 != Characters.end(); ++Iter1)
 {
  cout << "캐릭터 코드: " << Iter1->second._CharCd << "레벨" << Iter1->second._Level << "돈" << Iter1->second._Money << endl;
 }

 Characters.erase(Characters.begin(), Characters.end());

 //Charater 빈지 조사
 if (Characters.empty())
 {
  cout << "Characters는 비어 있습니다" << endl;
 }
}

LPSTR: char*와 같이 1바이트를 가리키는 포인터이다.

LPCSTR: const char*와 같음

LPTSTR : UNICODE(Wide Character) types.

-16 bit UNICODE character(WCHAR)를 가리키는 포인터

-유니코드를 지원하기 때문에 2바이트를 가리킨다.

LPCTSTR: const WCHAR* 와 같음.

'Computer Language > 데이터 통신' 카테고리의 다른 글

아이템 설계  (0) 2014.12.24
채팅  (0) 2014.11.13

+ Recent posts