Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void f1(int**, int);
- int f2(void(*)(int**, int), int**, int);
- int* pptr;
- int main() {
- int dim2 = 10;
- void(*pf1)(int**, int);
- pf1 = f1;
- int(*pf2)(void(*ppf1)(int**, int), int**, int);
- pf2 = f2;
- printf("%d\n", pf2(pf1, &pptr, dim2));
- for (int i = 0; i < dim2; i++) {
- printf("%d ", pptr[i]);
- }
- free(pptr);
- return 0;
- }
- void f1(int** m, int dim) {
- *(m) = (int*)malloc(dim * sizeof(int));
- }
- int f2(void(*fptr1)(int**, int), int** ptr, int dim) {
- fptr1(ptr, dim);
- for (int i = 0; i < 10; i++) {
- (*ptr)[i] = i * i + 1;
- }
- return pptr[8];
- }
Add Comment
Please, Sign In to add comment