#include <stdio.h>

#include <stdlib.h>

#include <time.h>

#include <Windows.h>


#define random(n) (rand() % (n))


typedef int(*Dm_callback)(void *, unsigned int, unsigned int);


typedef struct Dm {

void *context;

Dm_callback callbak;

} Dm;


int DmCallback(void *Dm, unsigned int time, unsigned int time2)

{

printf("callback %u - %u= %d\n", time2, time, time2 - time);

}


int main(void)

{

unsigned int time, time2;

unsigned int diff;

Dm *dm;


dm = malloc(sizeof(dm));

dm->context = dm;

dm->callbak = DmCallback;

time = GetTickCount();


while (1) {

Sleep(random (100));

time2 = GetTickCount();

if (time2 - time > 1000) {

dm->callbak(dm->context, time, time2);

time = time2;

}

}

return 0;

}

'Programming > C,C++' 카테고리의 다른 글

class와 OOP 예제2  (0) 2017.01.20
class와 OOP 예제  (0) 2017.01.20
Linear, Binary, BinaryRecursive 서치  (0) 2017.01.16
문자열 비교 후 버블 소트 2  (0) 2017.01.14
문자열 비교 후 버블 소트  (0) 2017.01.11
Posted by 루나s
,