Created
November 4, 2013 23:20
-
-
Save siscia/7311055 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
struct listnode | |
{ | |
void * element; | |
struct Node * next; | |
}; | |
typedef struct listnode ListNode; | |
typedef ListNode * ListNodePtr; | |
void * add_node(ListNodePtr *node, void * element){ | |
ListNodePtr newNode; | |
newNode = malloc( sizeof ( ListNode ) ); | |
if(newNode != NULL){ | |
newNode->element = element; | |
newNode->next = node;} | |
return newNode; | |
} | |
int main(){ | |
ListNodePtr a, b, c, d, current; | |
int g = 4, t = 7, k = 8, i, POI[10] = {23}; | |
for(i=1;i<10;i++) | |
POI[i] = i; | |
a = add_node(NULL, &g); | |
c = add_node(a, &k); | |
b = add_node(c, &t); | |
d = b; | |
for(i=0;i<10;i++) | |
d = add_node(d, &POI[i]); | |
current = d; | |
while(current != NULL){ | |
printf("node %d\n", *((int*)current->element)); | |
current = current->next;} | |
return 1;} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment