结构体里面要不要定义指针

giflib里面定义了很多结构体  每个结构体对应一种描述

结构体里面用了很多指针 存储GIF文件的各类数据

在使用的过程中常常致使指针偏移 delete 出错。

朋友建议我这样做:

 代码实现

struct item
{
    int s;
    int b;
};
struct sss
{
    int nCount;
    item it[1];
};

sss *p = (sss*)malloc(sizeof(int) + sizeof(item)*9999);
p->nCount = 100;
p->it[0];
p->it[1];

在调试过程中:

 头文件定义:

#if (defined DEBUG || defined _DEBUG)
#define MYTRACE printf("debug to here!")
#else
#define MYTRACE

程序中可以使用:

 MYTRACE

这样调试的时候 运行到MYTRCE就会打印 debug to here!

或者 使用

 MessageBox( 0"显示提示信息""标题", MB_ICON);

 

posted @ 2012-12-12 10:46  水上云天  阅读(630)  评论(0编辑  收藏  举报