头文件
#ifndef __HEAD_H__
#define __HEAD_H__#include<stdio.h>
#include<string.h>
#include<stdlib.h>typedef int datatype;
typedef struct Node
{
union
{
int len;
datatype data;
};
struct Node *next;
}*linkstack;
linkstack create(int flag);
int linkstack_push(linkstack stack, datatype e);
void output(linkstack stack);
linkstack free_space(linkstack stack);
#endif
自定义文件
#include "head.h"
/*
* function: 创建结点
* @param [ in]
* @param [out]
* @return 成功返回地址 失败返回NULL
*/
linkstack create(int flag)
{
linkstack top = (linkstack)malloc(sizeof(struct Node));
if(top == NULL)
return NULL;