循环队列的测试问题

pearl55 2007-08-14 03:18:19
#include "stdlib.h"
#include "stdio.h"
#define MAX_MSG_NUM 32
typedef enum{ MSG_ERROR = 0x1000, MSG_TIMER = 0x2000, MSG_KEY = 0x3000, MSG_SYSTEM = 0x4000 }E_MsgType;
//define system message
#define WIN_SHOW 0x4001
#define WIN_UPDATE 0x4002

//define MSG_ERROR long Parameter
#define CURE_FINISHED 0x1001
#define MOD_HD 0x1002
#define MOD_HF 0x1003
#define MOD_HP 0x1004
#define MOD_PF 0x1005
#define MOD_DF 0x1006
#define MOD_IF 0x1007
#define MOD_ST 0x1008//selftest
#define MOD_SC 0x1009//suck
#define MOD_CI 0x100A//circle
#define MOD_WH 0x100B//wash
#define MOD_ID 0x100C//idle

//define Timer word parameter
#define TIMER_POLL 0x2002
#define TIMER_CLOCK 0x2001
typedef struct strMessage
{
int type;// message type
int wPar;// word parameter
int lPar;//long parameter
int next;//pointer to the next message
}S_Message;
typedef struct strMsgQue
{
int head;
int tail;

S_Message msg[ MAX_MSG_NUM ];

}S_MsgQue;



extern int PostMsg( S_MsgQue * pQue, const int type, const int wPar, const int lPar )
{
if( ( pQue->tail + 1 ) % MAX_MSG_NUM == pQue->head )
{
return 0;
}
pQue->msg[ pQue->tail ].type = type;
pQue->msg[ pQue->tail ].wPar = wPar;
pQue->msg[ pQue->tail ].lPar = lPar;
pQue->tail = ( pQue->tail + 1 ) % MAX_MSG_NUM;
return 1;
}
extern int GetMsg( S_MsgQue * pQue, S_Message * pMsg )
{
if( ( pQue->head + 1 ) % MAX_MSG_NUM == pQue->tail )
{
return 0;
}
pQue->head = ( pQue->head + 1 ) % MAX_MSG_NUM;
pMsg->type = pQue->msg[ pQue->head ].type;
pMsg->wPar = pQue->msg[ pQue->head ].wPar;
pMsg->lPar = pQue->msg[ pQue->head ].lPar;
return pMsg->wPar;
}
extern void InitMsgQue( S_MsgQue * pQue )
{
pQue->head = MAX_MSG_NUM - 1;
pQue->tail = 0;
}
void main()
{
S_MsgQue *TEST;
InitMsgQue( TEST );
PostMsg( TEST, WIN_SHOW, TIMER_POLL, MOD_HD );
}




头一次写测试程序,不晓得怎么写啊
这就是我的整个程序,
主程序里,肯定有问题
大家帮我看一下啊,谢谢大家啊
...全文
139 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
pearl55 2007-09-26
  • 打赏
  • 举报
回复
这个可以结贴了
for_cyan 2007-09-26
  • 打赏
  • 举报
回复
有没有分啊;)
zgg___ 2007-09-26
  • 打赏
  • 举报
回复
那就结呗,呵呵。

33,006

社区成员

发帖
与我相关
我的任务
社区描述
数据结构与算法相关内容讨论专区
社区管理员
  • 数据结构与算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧