#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "person.h"
#include "person.h"

/*
 *
 * Uses person.c / person.h
 *
 */

int main() {
    person *p=NULL;
    int i;
    int ret_code;

    for (i=0; i<100; i++) {
        ret_code = add_one_person(&p, i+1, "Henry", "Rollins");
        if (ret_code != 0 ) {
            fprintf(stderr, "Mem alloc failure: %d\n", ret_code);
            return 2; // indicate errror to user
        }
    }

    /*
       Now you should assume there are 100 more persons and give them names
       as well. This will lead to you using accessing memory you have not
       allocated.
    */
    for (i=100; i<200; i++) {
        // sprintf is ok since we know what we have
        sprintf(p[i].first_name, "%s the%dth", "Henry", i);
        strcpy(p[i].family_name, "Rollins");
    }

    //  free_persons(p, i);
    return 0;
}
