2010년 1월 23일 토요일

[January 23, 2010] a font for programming

 

 

 Few days ago, when I studied MFC programming throught a web lecture, the teacher recommented to use the font of 'Consolas' which was developed by Microsoft for developers. Also, it's optimized for Microsoft Visual Studio 2005 & 2008 so that Simply I changed one option.

 

Here is the capture of Consolas font on Visual Studio 2008.

 

 

 

This is the capture of alphabet using Consolas.

 

 

 

You can download on the web site of MS page.

Here is a link:

http://www.microsoft.com/downloads/details.aspx?familyid=22e69ae4-7e40-4807-8a86-b3d36fab68d3&displaylang=en

 

 

Enjoy coding :)

 

 

 

 

- ps.
This blog is for my English abilities, and I'm not good at communicating in English. If you see grammatic, syntax or logical errors, or if you can't understand clearly, PLEASE COMMENT ON IT. Your comments definitely help me, and I really appreciate this. :)

 

- Written by Gordon

 

 

2010년 1월 13일 수요일

[News] Web 2.0 Suicide Machine

 

 

From NPR.

Here is the Link:

http://www.npr.org/templates/story/story.php?storyId=122379695

 

 

 

- Vocabraries (that were new to me):

 

 

fritter: make something into frit

fritter away: to waste time.

 

coax: persuade gently, gently make something work

 

euthanasia: painless killing to relieve suffering

 

violate: disregard something, disturb something

 

investigate: carry out official inquiry, take look

 

 

 

 

- My opinion:

That's why I don't use or visit in social-networking web sites. I highly recomment it.

 

 

 

 

 

2010년 1월 4일 월요일

[Scrap] Struct SYSTEM_INFO (System Programming)


It's from MSDN, and here is the link:
http://msdn.microsoft.com/en-us/library/ms724958(VS.85).aspx



SYSTEM_INFO Structure

Contains information about the current computer system. This includes the architecture and type of the processor, the number of processors in the system, the page size, and other such information.

Syntax

C++
typedef struct _SYSTEM_INFO {
  union {
    DWORD dwOemId;
    struct {
      WORD wProcessorArchitecture;
      WORD wReserved;
    } ;
  } ;
  DWORD     dwPageSize;
  LPVOID    lpMinimumApplicationAddress;
  LPVOID    lpMaximumApplicationAddress;
  DWORD_PTR dwActiveProcessorMask;
  DWORD     dwNumberOfProcessors;
  DWORD     dwProcessorType;
  DWORD     dwAllocationGranularity;
  WORD      wProcessorLevel;
  WORD      wProcessorRevision;
}SYSTEM_INFO;

Members

dwOemId

An obsolete member that is retained for compatibility. Applications should use the wProcessorArchitecture branch of the union.

wProcessorArchitecture

The processor architecture of the installed operating system. This member can be one of the following values.

Value Meaning
PROCESSOR_ARCHITECTURE_AMD64
9

x64 (AMD or Intel)

PROCESSOR_ARCHITECTURE_IA64
6

Intel Itanium Processor Family (IPF)

PROCESSOR_ARCHITECTURE_INTEL
0

x86

PROCESSOR_ARCHITECTURE_UNKNOWN
0xffff

Unknown architecture.

 

wReserved

This member is reserved for future use.

dwPageSize

The page size and the granularity of page protection and commitment. This is the page size used by the VirtualAlloc function.

lpMinimumApplicationAddress

A pointer to the lowest memory address accessible to applications and dynamic-link libraries (DLLs).

lpMaximumApplicationAddress

A pointer to the highest memory address accessible to applications and DLLs.

dwActiveProcessorMask

A mask representing the set of processors configured into the system. Bit 0 is processor 0; bit 31 is processor 31.

dwNumberOfProcessors

The number of physical processors in the system. To retrieve the number of logical processors, use the GetLogicalProcessorInformation function.

dwProcessorType

An obsolete member that is retained for compatibility. Use the wProcessorArchitecture, wProcessorLevel, and wProcessorRevision members to determine the type of processor.

Name Value

PROCESSOR_INTEL_386

386

PROCESSOR_INTEL_486

486

PROCESSOR_INTEL_PENTIUM

586

PROCESSOR_INTEL_IA64

2200

PROCESSOR_AMD_X8664

8664

 

dwAllocationGranularity

The granularity for the starting address at which virtual memory can be allocated. For more information, see VirtualAlloc.

wProcessorLevel

The architecture-dependent processor level. It should be used only for display purposes. To determine the feature set of a processor, use the IsProcessorFeaturePresent function.

If wProcessorArchitecture is PROCESSOR_ARCHITECTURE_INTEL, wProcessorLevel is defined by the CPU vendor.

If wProcessorArchitecture is PROCESSOR_ARCHITECTURE_IA64, wProcessorLevel is set to 1.

wProcessorRevision

The architecture-dependent processor revision. The following table shows how the revision value is assembled for each type of processor architecture.

Processor Value
Intel Pentium, Cyrix, or NextGen 586 The high byte is the model and the low byte is the stepping. For example, if the value is xxyy, the model number and stepping can be displayed as follows:

Model xx, Stepping yy

Intel 80386 or 80486 A value of the form xxyz.

If xx is equal to 0xFF, y - 0xA is the model number, and z is the stepping identifier.

If xx is not equal to 0xFF, xx + 'A' is the stepping letter and yz is the minor stepping.

 

Examples

For an example, see Getting Hardware Information.

Requirements

Minimum supported client Windows 2000 Professional
Minimum supported server Windows 2000 Server
Header Winbase.h (include Windows.h)

2009년 12월 30일 수요일

[09-12-29] my journel

Sometimes, I miss the time when I was being in love. It's taken already 2 years. No, 3 years? I don't remember exactly.. (Also, I don't want to remember this.)

Some of my friends asked me that when I'm going to meet someone. At every moment when I heard it, I just thought and asked myself why should I try to meet somebody, why should I give my efforts to meet a girl. Maybe after my heart was broken, I promissed to her that I never meet a new girl frined, and I'll wait for her. It was also my resolution for myself.. Time was going fast and fast from that event.

First, it was too hard for me. I didn't accept her words.(maybe because I had believed her too much.) I had never thought like to say goodbye or to be said goodbye. I was panic. everything was nothing to me. Even the light raising for me made me mad and angry.. But I had believed that it'll be just a moment and she will turn back to me again because I thouht I liked her much.

Now, I'm thinking of what I want. If she came to me again, was I happy? And were we going to be fine? I'm not sure.. It could possibly be fine or not. Anyway, I feel my heart seems to be forgotten about her a little. Sadly, It will probably take a lot of time to be forgotten perfectly.

I'm certain about my grades and efforts for my major, but I don't know about my girl's issues, damn it..



2009년 12월 27일 일요일

[C++] Function Pointer(3) (Solution)



It's my solution file compressed by zip.




* With finishing *

Maybe, it would be last about the test code of the function pointer. Later, I'm not sure whether I'm going to write about the function pointer in my server model (because there are so many extra-informations to explain).




- ps.
This blog is for my English abilities, and I'm not good at communicating in English. If you see grammatic, syntax or logical errors, or if you can't understand clearly, PLEASE COMMENT ON IT. Your comments definitely help me, and I really appreciate this. :)

- Written by Gordon


[C++] Function Pointer(2) (in class & with STL)



* Introduction *
Here is my second experience. I've often used class in C++, and I finally made it.


* Function Pointer in class (code & result)*
#include <iostream>
class cTemp1
{
private :
    int m_X ;
    int m_Y ;
    void (cTemp1::*m_PtrF1)(void) ;    
    int  (cTemp1::*m_PtrF2)(int _x, int _y ) ;
public:
    cTemp1(void);
    ~cTemp1(void);
    void Func1(void) ;
    int     Func2(int _x, int _y) ;
    void Run() ;
};
cTemp1::cTemp1(void) : m_X (5), m_Y(3)
{
    m_PtrF1 = &cTemp1::Func1 ;
    m_PtrF2 = &cTemp1::Func2 ;
}
cTemp1::~cTemp1(void)
{
}
void cTemp1::Func1(void)
{
    std::cout << "cTemp1::Func1" << std::endl ;
}
int     cTemp1::Func2(int _x, int _y)
{
    std::cout << "cTemp1::Func2" << "  X = " << _x+m_X << "  Y = " << _y+m_Y << std::endl ;
    return (_x + m_X + _y + m_Y) ;
}
void cTemp1::Run()
{
    (this->*m_PtrF1)() ;
    int Result = (this->*m_PtrF2)(20, 10) ;
    std::cout << "Result = " << Result << std::endl ;
}
int main()
{
    cTemp1 Instance ;
    Instance.Run() ;
    return 0 ;
}






* Function Pointer in class with STL::map (code & result) *
#include <iostream>

class cTemp2
{
private :
    typedef void(cTemp2::*fPtr)(int _x) ;
    std::map <int, fPtr>        m_Map ;
public :
    cTemp2(void) ;
    ~cTemp2(void) ;
    void Func1(int _x) ;
    void Func2(int _x) ;
    void Func3(int _x) ;
    void Func4(int _x) ;
    void Func5(int _x) ;
    void Func6(int _x) ;
    void Func7(int _x) ;
    void Func8(int _x) ;
    void Func9(int _x) ;
    void Func10(int _x) ;
    void Run() ;
};
cTemp2::cTemp2(void)
{
    // Insert to map
    m_Map[1] = &cTemp2::Func1 ;
    m_Map[2] = &cTemp2::Func2 ;
    m_Map[3] = &cTemp2::Func3 ;
    m_Map[4] = &cTemp2::Func4 ;
    m_Map[5] = &cTemp2::Func5 ;
    m_Map[6] = &cTemp2::Func6 ;
    m_Map[7] = &cTemp2::Func7 ;
    m_Map[8] = &cTemp2::Func8 ;
    m_Map[9] = &cTemp2::Func9 ;
    m_Map[10] = &cTemp2::Func10 ;

}
cTemp2::~cTemp2(void)
{
    // destroy map
    m_Map.clear() ;
}

void cTemp2::Func1(int _x) {std::cout << "cTemp2::Func1() is called with " << _x << std::endl ;}
void cTemp2::Func2(int _x) {std::cout << "cTemp2::Func2() is called with " << _x << std::endl ;}
void cTemp2::Func3(int _x) {std::cout << "cTemp2::Func3() is called with " << _x << std::endl ;}
void cTemp2::Func4(int _x) {std::cout << "cTemp2::Func4() is called with " << _x << std::endl ;}
void cTemp2::Func5(int _x) {std::cout << "cTemp2::Func5() is called with " << _x << std::endl ;}
void cTemp2::Func6(int _x) {std::cout << "cTemp2::Func6() is called with " << _x << std::endl ;}
void cTemp2::Func7(int _x) {std::cout << "cTemp2::Func7() is called with " << _x << std::endl ;}
void cTemp2::Func8(int _x) {std::cout << "cTemp2::Func8() is called with " << _x << std::endl ;}
void cTemp2::Func9(int _x) {std::cout << "cTemp2::Func9() is called with " << _x << std::endl ;}
void cTemp2::Func10(int _x) {std::cout << "cTemp2::Func10() is called with " << _x << std::endl ;}

void cTemp2::Run()
{
    int choice ;
    int count = 0 ;
    std::cout << "Enter a number between 1 and 10, 0 to end: " ;
    std::cin >> choice ;
    while (choice >= 1 && choice < 11) {
        std::map<int, fPtr>::iterator MapIt ;
        MapIt = m_Map.find (choice) ;
        if (MapIt->second != NULL) {
            (this->*(MapIt->second))(count) ;
        }
        count ++ ;
        std::cout << "Enter a number between 1 and 10, 0 to end: " ;
        std::cin >> choice ;
    }
    std::cout << "cTemp2::Run() end" << std::endl ;
}
int main()
{
   cTemp2 Instance2 ;
   Instance2.Run() ;
   return 0 ;
}







- ps.
This blog is for my English abilities, and I'm not good at communicating in English. If you see grammatic, syntax or logical errors, or if you can't understand clearly, PLEASE COMMENT ON IT. Your comments definitely help me, and I really appreciate this. :)

- Written by Gordon


[C++] Function Pointer(1) (Global function & using array)



* Introduction *
- A week ago, to parse network packets I used to do 'if' for all case. During optimizations, I turned from 'if' to 'function pointer with map'. I'm going to write about the function pointer as known as possible.


* Basic usage (code) *
#include <iostream>
void     Function1() ;
int        Function2(int _x, int _y) ;
int main()
{
    //////////////////////////////////////////////////////////////////////////
    // Test inside Main function
        // for void Function1() ;
    void (*PtrFunc1)() ;
    PtrFunc1 = Function1 ;
    PtrFunc1() ;
        // for int Function2(int, int) ;
    int  (*PtrFunc2)(int, int) ;
    PtrFunc2 = Function2 ;
    int result = PtrFunc2(20, 10) ;
    std::cout << "Result = " << result << std::endl ;
    return 0 ;
}
void Function1()
{
    std::cout << "Function1" << std::endl ;
}
int  Function2(int _x, int _y)
{
    std::cout << "Function2" << "  X = " << _x << "  Y = " << _y << std::endl ;
    return (_x + _y) ;
}






* Using with array *
#include <iostream>
void    ArrayFunction1(int _x) ;
void    ArrayFunction2(int _x) ;
void    ArrayFunction3(int _x) ;
int main()
{
    int choice ;
    void (*f[3])(int) = {ArrayFunction1, ArrayFunction2, ArrayFunction3} ;
    std::cout << "Enter a number between 0 and 2, 3 to end: " ;
    std::cin >> choice ;
    while (choice >= 0 && choice < 3) {
        (*f[choice])(choice) ;
        std::cout << "Enter a number between 0 and 2, 3 to end: " ;
        std::cin >> choice ;
    }
    return 0 ;
}
void ArrayFunction1( int _x )
{
    std::cout << "ArrayFunction1: _x = " << _x << std::endl ;
}
void ArrayFunction2( int _x )
{
    std::cout << "ArrayFunction2: _x = " << _x << std::endl ;
}
void ArrayFunction3( int _x )
{
    std::cout << "ArrayFunction3: _x = " << _x << std::endl ;
}







Reference : How To C++ Program 4th edition



- ps.
This blog is for my English abilities, and I'm not good at communicating in English. If you see grammatic, syntax or logical errors, or if you can't understand clearly, PLEASE COMMENT ON IT. Your comments definitely help me, and I really appreciate this. :)

- Written by Gordon