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
Debug warning 벨소리 변경 티스토리 초대장 서태지 Algorithm Brazil 영어 이메일 Java Error Case M480 spam mail It Wince5.0 english email C++ DVB DirectShow debugging 군대 Linux MP3 미라지폰 DVB-T Windows Mobile6.0 티스토리초대 isdbt English C VC++ 알고리즘 퇴사 개발자 project 1seg 출장 ISDB-T 음식 Dshow
 Calendar
«   2025/02   »
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
 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