From 52b29440f8f1310e0c074c8eb409e433c56bdd62 Mon Sep 17 00:00:00 2001 From: Teddy Date: Wed, 7 May 2014 03:17:32 +0800 Subject: rename --- compile_data/func_pointer.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 compile_data/func_pointer.c (limited to 'compile_data/func_pointer.c') diff --git a/compile_data/func_pointer.c b/compile_data/func_pointer.c new file mode 100644 index 0000000..e7b6484 --- /dev/null +++ b/compile_data/func_pointer.c @@ -0,0 +1,19 @@ +typedef void (*Func_t)(); +void f(Func_t func, int step) { + if (!step) return; + printf("i'm f\n"); + func(func, step - 1); +} +void g(void (*func)(), int step) { + if (!step) return; + printf("i'm g\n"); + func(func, step - 1); +} +int main() { + void (*func)(void (*ifunc)(), int step); + int x = 1; + if (x) func = f; + else func = g; + func(func, 5); + return 0; +} -- cgit v1.2.3-70-g09d2