📄 link_list_ope.c
字号:
#include "extern.h"
#include "struct.h"
/*========初始化链表========*/
void InitLink()
{
head=(struct Sell *)malloc(LEN);
p1=p2=head;
p1->next = NULL;
}
/*========申请空间========*/
struct Sell *NewNode()
{
struct Sell *t;
t=(struct Sell *)malloc(LEN);
if(t != NULL)
{
t->next = NULL;
}
return t;
}
/* Delete all Node from List exclude head*/
void FreeList(struct Sell *t)
{
struct Sell * buf;
buf = t;
if(buf->next != NULL)
FreeList(buf->next);
free(buf);
}
/*=============把数据保存到结构体==============*/
void InputDateToStruct(char *bar_code,char *mer_name,char *mer_unit,char *mer_spec,float mer_price,int amount,float total)
{
struct Sell *t=(struct Sell *)malloc(LEN);
memset(t, 0, LEN);
strncpy(t->bar_code,bar_code,strlen(bar_code));
strncpy(t->mer_name,mer_name,strlen(mer_name));
strncpy(t->mer_unit,mer_unit,strlen(mer_unit));
strncpy(t->mer_spec,mer_spec,strlen(mer_spec));
t->sell_price = mer_price;
t->mer_amount = amount;
t->total_money = total;
t->next = NULL;
p1=p2=head;
while (p1->next != NULL)
{
p1=p2=p1->next;
}
p1->next = t ;
p1=p2=t;
}
/*==============判断是否有相同的商品==========*/
struct Sell *IsTheSameMer(char *bar_code)
{
struct Sell * buf;
buf = head->next;
if(buf != NULL)
{
do
{
if(!strncmp(buf->bar_code,bar_code,strlen(buf->bar_code)))
{
return buf;
}
else
{
buf = buf->next;
continue;
}
}while (buf != NULL);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -