함수포인터 질문입니다.
글쓴이: kernelbomb / 작성시간: 월, 2004/08/02 - 12:36오전
#include <stdio.h> int calc(int a, int b) { return a + b; } int main(void) { int (*pcalc)(int, int); pcalc = calc; printf("num = %d\n", (*pcalc)(1,1)); return 0; }
보통 함수 포인터를 위와같이 선언하고 사용하게 되는데요.
호출부분에서 좀 헷갈리는데, 어떤 곳에서는 위에처럼 (*pcalc)(1,1)
로 하는곳도 있고 pcalc(1,1) 로 하는 곳도 있던데요.
둘중에 어느것이 정확한 것인가요? 둘다 경고나 에러는 없던데...
Forums:
둘다 맞습니다. 심지어는 (*******************pcalc)
둘다 맞습니다. 심지어는 (*******************pcalc)(1,1)도 맞습니다..-_-
자세한건 아래링크를 참조하세요.
http://bbs.kldp.org/viewtopic.php?t=20567
댓글 달기