Created
January 27, 2018 14:47
-
-
Save aipi/1ff8982534ddbdb7e71fe2b7dfbac95e to your computer and use it in GitHub Desktop.
Just enjoying callbacks
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 <iostream> | |
using namespace std; | |
void printall(char *xpto){ | |
for(int i=0; i < 3; i++){ | |
cout << *(xpto+i); | |
} | |
cout << "\n"; | |
} | |
void changeall(char *xpto){ | |
for(int i=0; i < 3; i++){ | |
*(xpto+i) = '.'; | |
} | |
} | |
void func(void (*wrapper)(char *), char *any){ | |
(*wrapper)(any); | |
} | |
int main(){ | |
char c[] = {'a', 's', 'r'}; | |
func(printall, c); | |
func(changeall, c); | |
func(printall, c); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment