tree.c
changeset 48 b94d657a9acb
parent 47 63adb261de90
child 61 4b4c97f179da
equal deleted inserted replaced
47:63adb261de90 48:b94d657a9acb
    36 
    36 
    37     for (i = 1; i < elements; i++) {
    37     for (i = 1; i < elements; i++) {
    38         if ((t->next = malloc (sizeof (T))) == NULL)
    38         if ((t->next = malloc (sizeof (T))) == NULL)
    39             break;
    39             break;
    40         t->next->data = GETRANDOM (rand_max);
    40         t->next->data = GETRANDOM (rand_max);
    41         t->next->next = NULL;
       
    42         t = t->next;
    41         t = t->next;
    43     }
    42     }
       
    43 
       
    44     t->next = NULL;
       
    45 
    44     return first;
    46     return first;
    45 }
    47 }
    46 
    48 
    47 int main (int argc, char **argv)
    49 int main (int argc, char **argv)
    48 {
    50 {
    49     T *t, *next;
    51     T *t, *next;
    50 
    52 
    51     if (argc != 3) {
    53     if (argc != 3) {
    52         printf ("Usage: %s elements rand_max\n", argv[0]);
    54         printf ("Usage: %s elements rand_max\n", argv[0]);
    53         return EXIT_SUCCESS;
    55         return EXIT_FAILURE;
    54     }
    56     }
    55 
    57 
    56     t = make_list (atoi (argv[1]), atoi (argv[2]));
    58     t = make_list (atoi (argv[1]), atoi (argv[2]));
    57 
    59 
    58     while (t) {
    60     while (t) {