Solution for Exercise 24-4
ex2403 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
#include "ex2403.h"
human person;
int main()
{
fillstructure();
printstructure();
return 0;
}
ex2404 input.c
#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
#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);
}
Notes
* The gcc command to create this multi-module program is:
Copyright © 1997-2025 by QPBC.
All rights reserved
