
修改如下,供参考:
#include<stdlib.h>
#include<stdio.h>
struct node_int;
typedef struct node_int *node;
struct node_int
{
void *data;
node next;
};
struct stack_int;
typedef struct stack_int *stack;
struct stack_int
{
node tos;
};
void reverse(stack *rsp,stack s)
{
node sc;
node c;
(*rsp) = (stack)malloc(sizeof(struct stack_int));
(*rsp)->tos = NULL;
sc = s->tos;
while(sc != NULL)
{
c = (node)malloc(sizeof(struct node_int));
sc->data = c->data;
c->next = (*rsp)->tos;
(*rsp)->tos = c;
sc = sc->next;
}
}