Hisworld.tistory.com
The hisWorld
(140)
hisworld_new
(0)
hisOld
(138)
Android
(7)
Computer Vision
(18)
JAVA
(4)
C/C++
(26)
열혈강의 C
(32)
TCP/IP socket
(12)
WinAPI
(16)
System Programming
(0)
etc
(23)
Plan
(0)
hisWorld
(0)
hiStory
(0)
hiStudy
(0)
hiSnap
(0)
홈
태그
미디어로그
위치로그
방명록
Windows Live Messenger
winapi
Join C
대학생 공모전
The Turing test page
훈스닷넷
C/C++ Reference
WIKI
/
/
블로그 내 검색
19. fct_ptr2.c (입력 데이터 유효성 검사 추가)
URUZ-7
2008. 2. 10. 16:55
2008. 2. 10. 16:55
#include
void SelFunction(int s); void Add(void); void Min(void); void Err_print(void); int main(void) { int sel; while(1) { printf("선택 : 덧셈(1), 뺄셈(2), 종료(3)"); scanf("%d", &sel); if(sel>3) Err_print(); else if(sel==3) break; else SelFunction(sel); } printf("프로그램이 종료되었습니다.\n"); return 0; } { printf("\n\a잘못된 입력 입니다.\n\n"); } void SelFunction(int s) { void(*fPtr)(void); if(s==1) fPtr=Add; if(s==2) fPtr=Min; fPtr(); } void Add(void) { int a,b; printf("덧셈을 위함 두 개의 숫자 입력: "); scanf("%d %d",&a,&b); printf("덧셈 결과 : %d\n\n",a+b); } void Min(void) { int a,b; printf("뺄셈을 위함 두 개의 숫자 입력: "); scanf("%d %d",&a,&b); printf("뺄셈 결과 : %d\n\n",a-b); }
invalid-file
공유하기
게시글 관리
구독하기
Hisworld.tistory.com
+ Recent posts
Powered by
Tistory
, Designed by
wallel
Rss Feed
and
Twitter
,
Facebook
,
Youtube
,
Google+
티스토리툴바