Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- /*
- /*. FUNCTIONS POINTERS - PART 1
- /* By MathsPhysic Code
- /*
- void display_differently( void (*func_pointer)(int value1, int value2), int a, int b){
- //you can write like this
- //(*func_pointer)(a, b);
- //or simply
- func_pointer(a, b);
- }
- //now let declare function to be pointed by function pointer
- void display_green(int a, int b){
- printf("I am the green function choose by function pointer\n");
- printf("\x1B[32m a = %d, b = %d\n", a, b); // i just print in green color
- }
- void display_yellow(int a, int b)
- {
- printf("I am the yellow function choose by function pointer\n");
- printf("\x1B[33m a = %d, b = %d\n", a, b); // i just print in yellow color
- }
- int main(){
- //display_differently( display_green , 8, 5);
- //if i want to display yellow , simply change first parameter
- display_differently(display_yellow, 8, 5);
- return (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement