#include #include #include // Make a new type that is a struct. typedef struct { int a; char name[10]; } NotQuiteObject; int main (int argc, char *argv[]) { // Put a variable of type NotQuiteObject on the stack NotQuiteObject s; // Put a variable that points to NotQuiteObject on the stack and give it a value // that points to a NotQuiteObject newly allocated on the heap NotQuiteObject *ptr = (NotQuiteObject *)malloc(sizeof(NotQuiteObject)); // Put values in the fields of the struct s.a = 4; strcpy( s.name, "Betsy" ); // Put values in the fields of the struct, via a pointer ptr->a = 5; strcpy( ptr->name, "Fred" ); // Print out the values. printf( "%d: %s, %d: %s\n", s.a, s.name, ptr->a, ptr->name ); return 0; }