I've always used to work with this kind of structures like this:Code:struct person { int age; char* name; };
I always first allocate memory, but often I see this form:Code:int main ( void ) { struct person per; /* some code */ per.name = malloc ( strlen ( "Test" ) + 1 ); strcpy ( per.name, "Test" ) /* some code */ }
Is there any problem with the latter way? I think there is but...Code:/*...*/ per.name = "Test" /*...*/
Can you comment this?
Thanks