Pointer to function with string
Code:
This is my first time trying to use a pointer to a function. I wrote this code and from what I understand it should work but it doesn't. Could someone please help me out.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char (*s1)(char* (*ptr)(void));
char set_text(void);
int main()
{
char *s2;
s1(set_text);
printf("%s\n", s2);
return 0;
}
char set_text(void) {
char text[] = "Hello World!";
char *tmp;
tmp = (char*)malloc((strlen(text) + 1) * sizeof(char));
strcpy(tmp, text);
return tmp;
}