tzpb8: I would think that a structure would really lend itself to what you are doing. Something like this?
Code:
#include <stdio.h>
struct record
{
char first[12];
char last[12];
int age;
};
void record_print(struct record *rec, size_t size)
{
printf("%-*s %-*s %s\n", (int)sizeof rec->first, "First Name",
(int)sizeof rec->last, "Last Name", "Age");
for ( ; size--; ++rec )
{
printf("%-*s %-*s %d\n", (int)sizeof rec->first, rec->first,
(int)sizeof rec->last, rec->last, rec->age);
}
}
int main(void)
{
struct record myrecord[] =
{
{ "Tree", "Strotter", 20 },
{ "Water", "Bridge", 21 },
{ "Dirt", "Stone", 18 },
};
record_print(myrecord, sizeof myrecord / sizeof *myrecord);
return 0;
}
/* my output
First Name Last Name Age
Tree Strotter 20
Water Bridge 21
Dirt Stone 18
*/