| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 862 人关注过本帖
标题:[求助]本人用TC2.0编写在图形模式下的软件,指正内存方面的的BUG
取消只看楼主 加入收藏
byluny
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-6-7
收藏
 问题点数:0 回复次数:3 
[求助]本人用TC2.0编写在图形模式下的软件,指正内存方面的的BUG

本程序在TC3.0中编译通过,但运行过程中出现内存溢出,请高手帮忙指正,急!急!
谢谢!


/* Note:Your choice is C IDE */

#include <fcntl.h>
#include <io.h>
#include <conio.h>
#include <dos.h>
#include <graphics.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <ctype.h>

#ifdef _MEDIUM_
printf("Program requires MEDIUM memory model\n");
exit(1);
#endif

#ifdef _cplusplus
#define _CPPARGS...
#else
#define _CPPARGS
#endif

#define RXD 0 /* REVI */
#define TXD 0 /*SAND */
#define LSB 0
#define MSB 1
#define IER 1
#define IIR 2
#define IERV 1
#define LCR 3
#define MCR 4
#define LSR 5
#define MSR 6
#define OUT2 0x08
#define ERTS 2
#define EDTR 1
#define EMPTY 0x20
#define READY 0x30
#define ICREG 0x20
#define IMASKREG 0x21
#define EOI 0x20
#define WAITCOUNT 5000
#define BUFFLEN 1024
#define ALTE 0x12
#define ALTQ 0x10

#define SER_BAUD_1200 96
#define SER_BAUD_2400 48
#define SER_BAUD_4800 24
#define SER_BAUD_9600 12

#define SER_STOP_1 0
#define SER_STOP_2 4
#define SER_BITS_5 0
#define SER_BITS_6 1
#define SER_BITS_7 2
#define SER_BITS_8 3
#define SER_PARITY_NONE 0
#define SER_PARITY_ODD 8
#define SER_PARITY_EVEN 24


/*定义一些常数*/
#define NO 0
#define YES 1
#define NONE -1
#define MAX_MENU 7/*根据情况改变可以在菜单显示的最大项*/
#define TXTx 30
#define TXTy 110
#define GRIDx 5
#define GRIDy 285
#define CH_ROW 1
#define CH_COL 2
#define BUTTON_row 40
#define BUTTON_col 20
#define BACKSPACE 8
#define OPENREC 50

/*全局参数*/
int X,Y;
int Selection;
int button,buttonDown,buttonUp,x,y;
long file_error=0,nOPENREC;
double long nPzl=2300,old_nPzl=0;
int SBvSaveType=NO;
char cPzldw; /* 读COM反回重量数 和 重量单位 */
char fERROR[6];
void *p;
size_t area;
long Times_n;
char cSBInPutValue[20];
int nFocus=-1,SBType=0,nPzdJINER=10; /* 控键焦点 司磅类型 0 一次过磅 1 二次过磅*/

int port;
int ComNum=1;
unsigned portaddr;
unsigned portf;
unsigned int baudtable[]={0x180,0xc0,0x60,0x30,0x18,0x0c,0x06};
unsigned char parityable[]={0x08,0x18,0x00,0x28,0x38};
unsigned char buffer[BUFFLEN];
int buffin=0;
int buffout=0;
int incount=0;
int outcount=0;
void interrupt(*vect_com)(_CPPARGS);


/*日期时间结构*/
typedef struct nDate{
int year;
int month;
int day;
int hour;
int min;
int sec;
}DATE;
DATE SYSDATETIME;
struct MENU
{
/*左上角*/
int x;
int y;
/*右下角*/
int x1;
int y1;
unsigned char Active[MAX_MENU];/* 菜单项是否激活的标志*/
char *head;/* 菜单的名字(可选项)*/
};

struct SBTXT
{
int x;
int y;
int x1;
int y1;
int nLEN;
char *NAME; /*数据名称 */
char TYPE; /* 数据类型 */
int index;
int enabled;
};

struct SBVALUE
{
long nBh;
char cCphm[20];
double long fMz;
double long fPz;
double long fJz;
DATE Mzdate;
DATE Pzdate;
float fDj;
long iJe;
char cKhmc[20];
char cHwmc[20];
char cSby[20];
};

struct Button
{
int x;
int y;
int w;
int h;
char name[12];
int action;
int enabled;
};

/*窗口*/
typedef struct Window
{
int x,y,w,h;
char tilte[10];
struct Button tclose;
};

/*文件显示链表*/
typedef struct BHfile
{
int BH;
int Pzbh;
}BHFILE;
BHFILE BHf_start,*BHfp;

typedef struct SBfile
{
struct SBVALUE sbv;
struct SBfile *prev;
struct SBfile *next;
}SBFILE;
SBFILE SBf_start;
SBFILE *SBf_node,*SBf_head;
/*
typedef struct PZfile
{
char CPHM[12];
long nPz;
DATE Pzdate;
struct PZfile *prev;
struct PZfile *next;
}PZFILE;
PZFILE PZf_start,*PZf_node;
*/
typedef struct YHfile
{
char yh[12];
char password[20];
struct YHfile *next;
}YHFILE;
YHFILE YHf_start,*YHf_node;

typedef struct INIfile
{
int com;
char setcom[20];
char admin[12];
char password[20];
char sn[60];
}INIFILE;
INIFILE INIf_start;
/*
typedef struct KHfile
{
char KHMC[20];
struct KHfile *next;
}KHFILE;
KHFILE KHf_start,*KHf_node;
*/
/* 表格显示 */
struct GRIDtxt
{
struct SBTXT gridBH;
struct SBTXT gridCPHM;
struct SBTXT gridMZ;
struct SBTXT gridPZ;
struct SBTXT gridJZ;
struct SBTXT gridMZD;
struct SBTXT gridPZD;
};
struct GRIDtxt gridTXT[5];

struct GRID
{
int x;
int y;
int w;
int h;
struct MENU up;
struct MENU down;
int enabled;
SBFILE *node;
int select;
};

struct GRID sbGrid={GRIDx,GRIDy,632,165,
GRIDx+613,GRIDy+1,GRIDx+627,GRIDy+19,1,2,3,4,5,6,7,"上一页",
GRIDx+613,GRIDy+136,GRIDx+627,GRIDy+155,1,2,3,4,5,6,7,"下一页",
1,NULL,-1};

int MouseOn(struct MENU *t);
void Process();
void Xorbar(int sx,int sy,int ex,int ey,int c);
void Show();
void Hide();
void Status();
void ShowTime();
void readtime();
void SBTXTINPUT(struct SBTXT *st,int bkYS,int YS);
void show_ch(int x,int y,char *china,int ROW_Y,int COL_X,int YS);
void show_ench(int x,int y,char *china,int ROW_Y,int COL_X,int YS);
void show_value(struct SBTXT *st,int YS);
void Hlight(struct MENU *t);
void Up(struct MENU *tm);
void PullMenuDown(char *H[],int n,struct MENU *tm);
void PullMenuUp(struct MENU *tm);
void HandleMenu(int n,struct MENU *tm);
void winp(struct MENU *t,int state);
void Win(int sx,int sy,int ex,int ey);
void Win_u(int sx,int sy,int ex,int ey,int ys);
void TXTWin(int sx,int sy,int ex,int ey,int YS);
void ButtonWin(struct Button *bt);
int MouseOnButton(struct Button *bt);
void Msg(char *m);
void Comments(void);
void End(void);
void DtoA(DATE *Ddt,char dt1[]);
void AddToTime(DATE *dDATETIME,DATE *dtsource);
int MouseOn1(int cx,int cy,int cx1,int cy1);
void StatusDown(void);
void StatusUp(void);
void nMsg(int m);
void ReadTime(DATE *dDATETIME,int type);
void resume(void);
void refresh(int type); /* 1 读毛重 2 读皮重 type=0 完成清空*/
int GridRefreshTXT(SBFILE *sbf);

int ReadGetBH(void);
void fSaveBHdatafile(BHFILE *pp);
SBFILE *fReadSBdataFile(void);
/* KHFILE *fReadKHdataFile(void);*/
/* PZFILE *fReadPZdataFile(void); */
INIFILE *fReadINIdataFile(void);
YHFILE *fReadYHdataFile(void);
void fSaveSBdatafile(SBFILE *pp);
/* void fSavePZdatafile(PZFILE *pp);*/
void fSaveYHdatafile(YHFILE *pp);
void fSaveINIdatafile(INIFILE *pp);
/* void fSaveKHdatafile(KHFILE *pp);*/
void fReadSBALLFile(void);
void Push(struct MENU *tm);
int checkSBvalue(void); /* 点击保存时检查项值*/
SBFILE *searchSBfileRecord(SBFILE *ssbv,int bh); /* 根据输入的编号查找记录 */
void freeSBfile(SBFILE *ssbv); /* 释放SBFILE链表 */
SBFILE *fSBvalueAddNew(SBFILE *ssbv); /* 在表头增加一条记录 */
void DrawGrid(struct GRID *sbG,struct GRIDtxt sbGa[],SBFILE *SBf,int n);
void DrawGRIDSBTXT(struct GRIDtxt *st,SBFILE *sbf,int n,int bkYS,int YS);
int GridRefreshTXT(SBFILE *sbf);
void fSBvalueSaveNew(void);
void WcBetton_click(int n);

unsigned char getb();
void SerInit(int baud,int configuration);
void SerOpen(void);
void SerClose();
void Getportaddr(int port);
void ShowSbData(unsigned char sbcomdata[]);

/* 通过下面的参数用户可以改变按钮的位置。*/
struct SBVALUE SBvalue={0,"",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.5,10,"","","司磅员"};
struct MENU File={2,20,52,38};
struct MENU Edit={105,20,155,38};
struct MENU Help={204,20,254,38};
struct MENU Close={620,2,635,16};
struct MENU Baojin={50,2,450,17};

struct SBTXT BH={TXTx,TXTy,TXTx+250,TXTy+20,12,"编号",'C',0,0};
struct SBTXT CPHM={TXTx+285,TXTy,TXTx+570,TXTy+20,12,"车牌",'C',1,0};
struct MENU selCp={TXTx+320,TXTy,TXTx+350,TXTy+20};

struct SBTXT MZ={TXTx,TXTy+25,TXTx+250,TXTy+45,8,"毛重",'F',2,0};
struct SBTXT MZDATE={TXTx+285,TXTy+25,TXTx+570,TXTy+45,18,"毛重日期",'C',3,0};

struct SBTXT PZ={TXTx,TXTy+50,TXTx+240,TXTy+70,8,"皮重",'F',4,0};
struct SBTXT PZDATE={TXTx+285,TXTy+50,TXTx+570,TXTy+70,18,"皮重日期",'C',5,0};

struct SBTXT JZ={TXTx,TXTy+75,TXTx+250,TXTy+95,8,"净重",'F',6,0};
struct SBTXT SBY={TXTx+285,TXTy+75,TXTx+570,TXTy+95,12,"司磅员",'C',7,0};

struct SBTXT DANJ={TXTx,TXTy+100,TXTx+250,TXTy+120,3,"单价",'F',8,0};
struct SBTXT JINER={TXTx+285,TXTy+100,TXTx+570,TXTy+120,4,"金额",'I',9,0};

struct SBTXT KHMC={TXTx,TXTy+125,TXTx+200,TXTy+145,12,"客户",'C',10,0};
struct MENU selKh={TXTx+201,TXTy+125,TXTx+250,TXTy+145};
struct SBTXT HWMC={TXTx+285,TXTy+125,TXTx+500,TXTy+145,12,"货物",'C',11,0};
struct MENU selHw={TXTx+501,TXTy+125,TXTx+551,TXTy+145};

struct Button ButtonMz={120,TXTy+150,40,20,"毛重",1,1};
struct Button ButtonPz={170,TXTy+150,40,20,"皮重",1,1};
struct Button ButtonBc={350,TXTy+150,40,20,"保存",1,0};
struct Button ButtonDy={400,TXTy+150,40,20,"打印",1,0};
struct Button ButtonWc={450,TXTy+150,40,20,"完成",1,1};
struct Button ButtonSpz={TXTx+243,TXTy+50,40,20,"选皮",1,1};

struct tm *SysTime;

搜索更多相关主题的帖子: 内存 图形 BUG 软件 模式 
2007-06-07 09:58
byluny
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-6-7
收藏
得分:0 
回复:(byluny)[求助]本人用TC2.0编写在图形模...
完整的原程序
2007-06-07 10:02
byluny
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-6-7
收藏
得分:0 
回复:(byluny)[求助]本人用TC2.0编写在图形模...
yX3vYtRA.txt (54.22 KB) [求助]本人用TC2.0编写在图形模式下的软件,指正内存方面的的BUG


2007-06-07 10:04
byluny
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-6-7
收藏
得分:0 
怎么还没有人能找出原因呢?
2007-06-22 17:30
快速回复:[求助]本人用TC2.0编写在图形模式下的软件,指正内存方面的的BU ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021500 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved