IT 취미생활.  
Front Page
Tag | Location | Media | Guestbook | Admin   
 
'Callback Function'에 해당하는 글(1)
2008.03.10   간단한 Callback Function 예제


간단한 Callback Function 예제
간단한 Callback 예제 C / C++

2007/07/28 08:35

복사 http://blog.naver.com/liezzang99/40329125

// TestCallbackFunction.cpp : Defines the entry point for the console application.
//

#include <stdio.h>
#include <stdlib.h>
#include <string.h>


#define BOOL unsigned int
#define TRUE 1
#define FALSE 0

typedef BOOL (*RonieTest_Callback)( int nValue );

typedef struct
{
 int number;
 char *name;
 RonieTest_Callback bCount_CB;
} WmMyInfo;


BOOL fnConditionCallback_cb( int nValue )
{
 BOOL bRet = 0;
 if( 0 == (nValue % 2) )
 {
   bRet = 1;
 }
 return bRet;
}


WmMyInfo *TestLoopFunction( WmMyInfo *pInfo )
{
 while(1)
 {
  pInfo->number++;
  if( pInfo->number == 10 )
  {
   BOOL bRet = pInfo->bCount_CB( pInfo->number );
   if( bRet == TRUE )
   {
    pInfo->name = new char[5];
    memset( pInfo->name, 0, sizeof(char)*5 );
    strncpy( pInfo->name, "Even", strlen("Even") );
    return pInfo;
   }

   return  pInfo;
  }
 }
}


int main(int argc, _TCHAR* argv[])
{
 WmMyInfo *pMyInfo = new WmMyInfo;
 pMyInfo->number = 0;
 pMyInfo->bCount_CB = fnConditionCallback_cb;

 pMyInfo = TestLoopFunction( pMyInfo );

 printf( "Number : %s", pMyInfo->name );


 delete []pMyInfo->name;
 delete pMyInfo;

 return 0;
}



BLOG main image
취미생활
 Notice
 Category
분류 전체보기 (191)
매일매일갱생 (83)
서버개발 (1)
임베디드개발 (12)
Programming (80)
Personal Projects (6)
유용한 프로그램 (0)
 TAGS
Java C isdbt Error Case 군대 project 개발자 debugging VC++ Windows Mobile6.0 티스토리 초대장 Linux ISDB-T C++ Algorithm warning 벨소리 변경 Wince5.0 티스토리초대 It spam mail DVB 1seg DirectShow 서태지 알고리즘 Dshow 미라지폰 출장 Debug M480 영어 이메일 음식 English DVB-T 퇴사 english email Brazil MP3
 Calendar
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
 Recent Entries
 Recent Comments
 Recent Trackbacks
 Archive
 Link Site
zextor
괴짜 프로그래머의 일상사~@@
Gag & Peace, and more..
Kazakhstan Almaty.......
Min-A
Sadgarret
Steve Yoon's log
가슴 뛰는 삶을 살아라
오스틴 파워
GUI sin
melanie parker_Lady
제레미의 TV 2.0 이야기..
 Visitor Statistics
Total :
Today :
Yesterday :
rss