All pastes #369021 Raw Edit

Unnamed

public c v1 · immutable
#369021 ·published 2007-02-23 14:51 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#define dumpptr(P) printf("%u\n", (unsigned int) (P));typedef struct TreeNode {	int label;	struct TreeNode* next;} TreeNode;TreeNode* treenode_new(int l, TreeNode* v) {	TreeNode* t;	t = malloc(sizeof(TreeNode));	t->label = l;	t->next = v;	return t;}TreeNode** treenode_find_blank(TreeNode* t) {		/* gets the address of root */	TreeNode** q = &t;	while (*q) {		/* gets pointer to the pointer to next */		q = &((*q)->next);	}		return q;	}int main (void) {	TreeNode* a;    TreeNode** dest;	/* creates root node */	a = treenode_new(0, NULL);	a->label = 10;		/* find first blank node*/	dest = treenode_find_blank(a);		/* sets the destination node to a new node */	*dest = treenode_new(1, NULL);		/* next equals to dereferenced dest */	dumpptr(a->next);	dumpptr(*dest);		return 0;}