aboutsummaryrefslogtreecommitdiff
path: root/tests/test32.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test32.c')
-rw-r--r--tests/test32.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/test32.c b/tests/test32.c
new file mode 100644
index 000000000..f861b2ad4
--- /dev/null
+++ b/tests/test32.c
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "utlist.h"
+
+#define BUFLEN 20
+
+typedef struct el {
+ char bname[BUFLEN];
+ struct el *next, *prev;
+} el;
+
+int main()
+{
+ el *name, *tmp;
+ el *head = NULL;
+
+ char linebuf[BUFLEN];
+ FILE *file;
+
+ file = fopen( "test11.dat", "r" );
+ if (file == NULL) {
+ perror("can't open: ");
+ exit(-1);
+ }
+
+ while (fgets(linebuf,BUFLEN,file) != NULL) {
+ name = (el*)malloc(sizeof(el));
+ if (name == NULL) {
+ exit(-1);
+ }
+ strcpy(name->bname, linebuf);
+ DL_PREPEND(head, name);
+ }
+ /* DL_SORT(head, namecmp); */
+ DL_FOREACH(head,tmp) {
+ printf("%s", tmp->bname);
+ }
+
+ fclose(file);
+
+ return 0;
+}