It's safe initialize pointers using compound literals in such way and it's possible at all?:
#include <stdio.h>
#include <string.h>
void numbers(int **p)
{
*p = (int []){1, 2, 3};
}
void chars(char **p)
{
*p = (char[]){'a','b','c'};
}
int main()
{
int *n;
char *ch;
numbers(&n);
chars(&ch);
printf("%d %c %c\n", n[0], ch[0], ch[1]);
}
output:
1 a b
I don't understand exactly how it's works, does it's not the same as init pointer with local variable?
also if i try to print:
printf("%s\n", ch);
It's print nothing.