fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. struct el_stack {
  6. char symbol;
  7. struct el_stack * new;
  8. };
  9.  
  10. typedef struct el_stack *p_el_stack;
  11.  
  12. void push(p_el_stack *head, char x)
  13. {
  14. p_el_stack tmp = (p_el_stack)malloc(sizeof(struct el_stack));
  15. tmp->symbol = x;
  16. tmp->new = *head;
  17. *head = tmp;
  18. }
  19.  
  20. char pop (p_el_stack *head)
  21. {
  22. char resymb;
  23. p_el_stack tmp = *head;
  24. resymb = tmp->symbol;
  25. *head = tmp->new;
  26. free(tmp);
  27. return(resymb);
  28. }
  29.  
  30.  
  31. int main(void) {
  32. char str[255];
  33. p_el_stack *stack;
  34. fgets(str,255,stdin);
  35. int i,j;
  36. for(i=0; i<strlen(str); i++) push(&stack, str[i]);
  37. for(j=0; j<i; j++) str[j]=pop(&stack);
  38. printf("%s\n",str);
  39. return 0;
  40. }
Success #stdin #stdout 0s 2292KB
stdin
Standard input is empty
stdout
�W�