order_by_int renamed to order_by_num + some experiments with lists
[svn/Cll1h/.git] / demos / ansi-c / float-list-plain-c.c
diff --git a/demos/ansi-c/float-list-plain-c.c b/demos/ansi-c/float-list-plain-c.c
new file mode 100644 (file)
index 0000000..0501873
--- /dev/null
@@ -0,0 +1,60 @@
+#include <stdio.h>\r
+#include <stdlib.h>\r
+\r
+\r
+struct Node \r
+{\r
+        float f;\r
+        struct Node* next;\r
+};\r
+\r
+void IterateList (struct Node* HeadList);\r
+struct Node* makelist(struct Node** Head, struct Node** Tail);\r
+\r
+struct Node* makelist(struct Node** Head, struct Node** Tail)\r
+{\r
+        struct Node* new = (struct Node *)malloc(sizeof (struct Node));\r
+        new->next = NULL;\r
+\r
+        if (*Head == NULL)\r
+        {\r
+                *Head = new;\r
+                *Tail = *Head;\r
+        }\r
+        else\r
+        {\r
+                (*Tail)->next = new;\r
+                *Tail = new;\r
+        }\r
+        return (new);\r
+}\r
+void IterateList (struct Node* HeadList)\r
+{\r
+        struct Node* current = HeadList;\r
+\r
+        while (current != NULL)\r
+        {\r
+                printf("The float you entered is %f\n",current->f);\r
+                current = current->next;\r
+        }\r
+}\r
+int main(void)\r
+{\r
+        struct Node* head = NULL;\r
+        struct Node* tail = NULL;\r
+        struct Node* curr = NULL;\r
+        int i;\r
+\r
+        for(i=0; i < 20; i++)\r
+        {\r
+                /* create node */\r
+                curr = makelist(&head,&tail);\r
+                printf("Enter float :\n");\r
+                scanf("%f", &(curr->f));\r
+        }\r
+\r
+        /* now iterate the list */\r
+        IterateList(head);\r
+\r
+        return 0;\r
+}\r
This page took 0.142161 seconds and 4 git commands to generate.