250x250
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 네모안
- node.js
- rasppi3
- 난방비절약
- EditText
- IOT
- ReactNative
- 경동
- todoist
- nodejs
- 린나이온도조절기
- 온도조절기
- npm moment
- 라온익스
- debounce
- react-native
- 기름보일러
- anydo
- 에버노트
- Raspberry Pi
- Swipes
- Node
- 온도센서
- xcode11
- REACT
- 가스비절약
- 가스요금폭탄
- 나비엔
- __attribute__
- evernote
Archives
- Today
- Total
어허
function pointer 본문
728x90
typedef struct { BYTE command[32]; void (*set)(BYTE *); BYTE hidden; BYTE usage[128]; }Fp; code Fp fn_cli[] = { {"show all", show_all_config, ON, " show all : can you see all config", }, } void main(){ // cmd_string input... for(i=0;i<( sizeof(fn_cli) / sizeof(fn_cli[0]) );i++){ if(!strncmp(cmd_string, fn_cli[i].command, strlen(fn_cli[i].command))){ argv[1]=&(*cmd_string)+strlen(fn_cli[i].command)+1; fn_cli[i].set(argv[1]); } } }
이거 처음 알고 썼을때 완전 신세경 @_@
완전 편함
정리하면, 입력받는 루틴엥서 "show all"이란 명령이 들어오면 배열 비교해서 같은 글씨 있나 확인하고
같으면 struct의 function pointer 부분의 함수 show_all_config 함수 호출,
끝!
728x90
'개발 > C(C++)' 카테고리의 다른 글
select 함수 사용시 주의할 점 ! tv 를 while 문 밖에 쓰면 리셋된다 (0) | 2011.12.14 |
---|---|
crc32 코드 (0) | 2010.12.07 |
CRC : CRC-16, CRC-32에 대한 설명과 구현 (0) | 2010.11.23 |
리눅스 c 에서 itoa (0) | 2010.11.16 |
[socket] bind : error address already in use (0) | 2010.11.05 |
Comments