Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2651703
  • 博文数量: 416
  • 博客积分: 10220
  • 博客等级: 上将
  • 技术积分: 4193
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-15 09:47
文章分类

全部博文(416)

文章存档

2022年(1)

2021年(1)

2020年(1)

2019年(5)

2018年(7)

2017年(6)

2016年(7)

2015年(11)

2014年(1)

2012年(5)

2011年(7)

2010年(35)

2009年(64)

2008年(48)

2007年(177)

2006年(40)

我的朋友

分类: C/C++

2010-04-30 16:46:10

引用 :

在VS2008编译有问题,下面测试是OK的

#include
#include "form.h"
#include
#include
#include
void **darray_new(int row, int col, int size)

 void **arr;
 arr = (void **) malloc(sizeof(void *) * row + size * row * col);
 if (arr != NULL)
 {
  void *head;
  head = (void *)(arr + sizeof(void *) * row);
  memset(arr, 0, sizeof(void *) * row + size * row * col);
  while (row--)  
   arr[row] =  (unsigned char*)head + size * row * col;  
 }
 return arr;
}
void darray_free(void **arr)
{
 if (arr != NULL)
  free(arr); 
}
struct student
{
 char name[128];
 int pid;
};
//struct xxx **x;
//x = (struct xxx **) darray_new(5, 4, sizeof(struct xxx));
int main(int argc, char **argv)
{
 struct student **sd;
 sd = (struct student **) darray_new(5, 4, sizeof(struct student));
 strcpy(sd[1][3].name,"ass");
 sd[1][3].pid = 100;
 strcpy(sd[1][4].name,"ccccc");
 sd[1][4].pid = 101;
 
 char *pStr = "master";
 int f = 12345;
 int *n = &f;
 qDebug() << "char = " << pStr + 1 << "int = " << *(n+1);
 darray_free(sd);
 QApplication app(argc, argv);
 Form form;
 form.show();
 return app.exec();
}
 
阅读(1351) | 评论(1) | 转发(0) |
0

上一篇:testsprites2 of sdl

下一篇:va_list 用法

给主人留下些什么吧!~~

chinaunix网友2010-05-06 17:59:18

http://wyw.dcweb.cn/dllfaq.htm