I have a task to do and the content of the task is:
Please suggest a definition of linked list, which will keep the person\'s name and age in a flexible stru
my guess: a flexible struct would be one that could handle any age and any name.
A unsigned int
field would handle any age (within reason).
A char *
field would handle any name.
The struct itself would be:
struct nameAge { unsigned int age; char * pName; };
an instance of the struct would be:
struct nameAge myNameAge;
Setting the age
field would be:
myNameAge.age = ageValue;
Setting the name
field would be:
myNameAge.name = malloc( numCharactersInName+1 );
strcpy( myNameAge.name, nameString );
How the code obtained the ageValue for age and/or the characters for NameString is up to the programmer to decide/implement.