#include <stdio.h>
#define DEBUG 1
/* Terry Harvey CISC105 Section 21 TA Aaron*/

/* Sample program for class */

struct rational {
    int numer;
    int denom;
};

int main(){
    int numer, denom;
    int i = 0, count;
    struct rational * newRat;
    struct rational * rats[100];

    printf("Enter a numerator and denominator, or denom == 0 to stop: ");
    scanf("%d%d", &numer, &denom);

    while(denom != 0 && i < 100){

        rats[i] = (struct rational *)malloc( sizeof(struct rational) );

        rats[i]->numer = numer;
        rats[i]->denom = denom;

        if (DEBUG) printf("%d / %d\n", rats[i]->numer, rats[i]->denom);

        printf("Enter a numerator and denominator, or denom == 0 to stop: ");
        i++;
        scanf("%d%d", &numer, &denom);
    }

    count = i; //why?
    for(i = 0; i < count; i++)
        free(rats[i]);

    return 0;
}
