codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include<stdio.h> #include<stdlib.h> struct st{ int value1; int value2; struct st *next; }; struct st *new_st(int v1, int v2); void free_sts(struct st *s); void re_print_sts(struct st *s); int main() { struct st *head = NULL; struct st *s; s = new_st(-1, 1); s->next = head; head = s; s = new_st(-2, 12); s->next = head; head = s; s = new_st(-3, 23); s->next = head; head = s; re_print_sts(head); free_sts(head); return 0; } struct st *new_st(int v1, int v2) { struct st *s; if((s = (struct st *)malloc(sizeof(struct st))) != NULL){ s->value1 = v1; s->value2 = v2; } return s; } void re_print_sts(struct st *s) { if(s != NULL){ printf("(%d, %d)\n",s->value1, s->value2); re_print_sts(s + 1); } }
Private
[
?
]
Run code
Submit