Created
March 12, 2014 19:07
-
-
Save keizo042/9514025 to your computer and use it in GitHub Desktop.
関数ポインタの練習。Cはメモリを直接弄れて全能感がある。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
typedef int (*func)(int x, int y); | |
int cat(int, int); | |
int dog(int, int); | |
int bird(int, int); | |
int | |
main() | |
{ | |
func functions[] ={ | |
cat, | |
dog, | |
bird, | |
}; | |
int i; | |
for(i=0;i <3;i++){ | |
(*functions[i])(i*1,i*2); | |
} | |
} | |
int cat(int x, int y) | |
{ | |
printf("there are %d cats and %d times nyaa\n",x,y); | |
} | |
int dog(int x, int y) | |
{ | |
printf("there are %d dogs and %d times bow\n",x,y); | |
} | |
int bird(int x, int y) | |
{ | |
printf("there are %d bird and %d times fly away\n",x,y); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment