Larry C. answered 05/18/19
Computer Science and Mathematics professional
#include <stdio.h>
#include <malloc.h>
#include <string.h>
struct Person {
char* name;
int age;
};
void main() {
Person person;
person.age = 20;
person.name = (char*)calloc(10, sizeof(char));
strcpy(person.name, "armstrong");
printf("Person's name: %s and age: %d\n", person.name, person.age);
Person* otherPerson;
otherPerson = (Person*)calloc(1, sizeof(Person));
otherPerson->age = 30;
otherPerson->name = (char*)calloc(9, sizeof(Person));
strcpy(otherPerson->name, "vladimir");
printf("Person's name: %s and age: %d\n", otherPerson->name, otherPerson->age);
/* other way of printing otherPerson info */
printf("Person's name: %s and age: %d\n", (*otherPerson).name, (*otherPerson).age);
}