Solution for Exercise 24-4

ex2403 ex2303.h Header File

#include <stdio.h>
#include <stdlib.h>

/* prototypes */

void fillstructure(void);
void printstructure(void);

/* constants */

/* variables */

struct thing {
    char name[32];
    int age;
    };

typedef struct thing human;

ex2404 main.c Module

#include "ex2403.h"

human person;

int main()
{
    fillstructure();
    printstructure();
    return 0;
}

ex2404 input.c Module

#include "ex2403.h"

extern human person;

void fillstructure(void)
{
    printf("Enter your name: ");
    fgets(person.name,31,stdin);
    printf("Enter your age: ");
    scanf("%d",&person.age);
}

ex2404 output.c Module

#include "ex2403.h"

extern human person;

void printstructure(void)
{
    printf("You are %s\n",person.name);
    printf("And you are %d years old.\n",person.age);
}

Output

Enter your name: Danny
Enter your age: 39
You are Danny

And you are 39 years old.

Notes

* The command to create this multi-module program at the prompt is: