intro.c
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#include "intro.h"
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
int compute(int input, int (*executor)(int))
|
||||
{
|
||||
|
||||
return executor(input);
|
||||
}
|
||||
|
||||
void isa(void){ printf("Hello Isabelle!\n");}
|
||||
void idky(void){ printf("I don't know you!\n");}
|
||||
void bla(void){ printf("Good night Blathers!\n");}
|
||||
void tom(void){ printf("Hi Tom Nook.\n");}
|
||||
void res(void){ printf("How are you doing Mr. Resetti?\n");}
|
||||
|
||||
|
||||
void (*greet(char *name)) (void)
|
||||
{
|
||||
if(!name) return idky;
|
||||
|
||||
if (strcmp(name, "Isabelle") == 0) return isa;
|
||||
else if (strcmp(name, "Tom Nook") == 0) return tom;
|
||||
else if (strcmp(name, "Blathers") == 0) return bla;
|
||||
else if (strcmp(name, "Mr. Resetti") == 0) return res;
|
||||
else return idky;
|
||||
}
|
||||
|
||||
/*
|
||||
int next(int n)
|
||||
{
|
||||
return n + 1;
|
||||
}
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
int main(void)
|
||||
{
|
||||
int n = 3;
|
||||
printf("compute(%d, &next) = %d\n", n, compute(n, &next));
|
||||
}
|
||||
*/
|
||||
/*
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
(void)argc;
|
||||
(*greet(argv[1]))();
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user