#include
#include
void
getstr(char *&retstr)
{
char *tmp = (char *)malloc(25);
strcpy(tmp, \"hello,world\");
retstr = tmp;
}
There is an interesting trick in libgmp which emulates references:
typedef mpz_t __mpz_struct[1];
and then you can write like this:
mpz_t n;
mpz_init(n);
...
mpz_clear(n);
I would not recommend to use this method, because it may be incomprehensible for others, it still does not protect from being a NULL: mpz_init((void *)NULL), and it is as much verbose as its pointer-to-pointer counterpart.