Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- //node structure
- struct s_stack {
- char key;
- struct s_stack *next;
- };
- void addElt (struct s_stack *theStack,
- char elt);
- int main()
- {
- printf("Bonjour");
- bien_parenthese("(abcdc(ee(f)))");
- return 0;
- }
- //add an element to a s_stack
- void addElt (struct s_stack *theStack,
- char elt)
- {
- struct s_stack *head = theStack;
- struct s_stack *newElt = malloc(sizeof(struct s_stack));
- newElt->key = elt;
- newElt->next = NULL;
- while (theStack->next != NULL)
- theStack = theStack->next;
- theStack->next = newElt;
- theStack = head;
- }
- //count elements of a s_stack
- int countStack (struct s_stack theStack)
- {
- int i = 0;
- while (theStack.next != NULL)
- {
- theStack = *theStack.next;
- i++;
- }
- return (i);
- }
Add Comment
Please, Sign In to add comment