I want to return a string from a function (in the example funzione) to main. How to do this? Thank you!
#include #include
You can do this as
char *funzione (void) { char *stringFUNC = malloc(SIZE); strcpy (stringFUNC, "Example"); return stringFUNC; }
In main, call it as
main
int main() { char stringMAIN[SIZE]; char *ptr = funzione () ... free(ptr); return 0; }