typedef struct {
char name[10];
} A;
A * inst = get_instance_of_A();
char *str = g_strdup ( inst->name );
The last line doesn't compile. I also tried &(inst->name) with no luck. The error I get is:
Error: char is not a structure type.
I understand that char[] and char * are different types altogether. But shouldn't g_strdup be able to take a starting position of a C string and dupe it? If I do the following it works:
char temp[10];
strncpy(temp,inst->name,9);
char *str = g_strdup ( temp );
How can I achieve what I am trying to do without making a local char array copy? I think I am not passing the argument correctly in the fist scenario as in both cases g_strdup is being passed a char array.