Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- typedef struct s_s
- {
- char *s;
- struct s_s *next;
- } t_s;
- t_s *push(t_s **b, char *s)
- {
- t_s *new;
- if (!(new = malloc(sizeof(t_s))))
- return (NULL);
- new->s = s;
- new->next = *b;
- *b = new;
- return (*b);
- }
- void disp(t_s *t)
- {
- while (t)
- {
- printf("%s\n", t->s);
- t = t->next;
- }
- }
- int main()
- {
- t_s *t;
- t = NULL;
- if (!push(&t, "1"))
- return (1);
- if (!push(&t, "2"))
- return (1);
- if (!push(&t, "3"))
- return (1);
- printf("Avant: %s\n\n", t->s);
- disp(t);
- printf("\nApres: %s\n", t->s);
- return (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement