To illustrate the use of those functions, here is an example.
#include <stdio.h>
#include <stdlib.h>
#include "list.h"
LINK string_to_list(char []);
void print_list(LINK);
int count_rec(LINK);
int main(void)
{
LINK h;
h = string_to_list("ABC");
printf("The resulting list is\n");
print_list(h);
printf("\nThis list has %d elements.\n", count_rec(h));
return 0;
}
The output of the program is
The resulting list is
A --> B --> C --> NULL
This list has 3 elements.
No comments:
Post a Comment