a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 46|回复: 0

[程序员] 2012年软件水平考试程序员辅导笔记之C语言封送结构体数组知识

[复制链接]
发表于 2012-8-2 08:51:15 | 显示全部楼层 |阅读模式
 在使用第三方的非托管API时,我们经常会遇接事数为指针或指针的指针这种情形,
9 {7 J- O8 r2 s2 k* H; G7 v$ m  一般我们会用IntPtr指向我们需要传递的参数地址;   t' E1 G, r9 U$ G8 y: F$ D
  可是当碰着这种一个导出函数时,我们若何正确的使用IntPtr呢, % c. V0 h' m2 u
  extern “C” __declspec(dllexport) int GetClass(Class pClass[50]) ; 5 T* y- w2 u3 Q% z1 R
  因为这种情形也经常可能碰着,所以我建造了2个示例轨范来演示下若何措置这种非托管函数的挪用!
/ U- U( Y: M) U6 Y/ {* G' o' z& J  首先建树一个C++ 的DLL 设置一个如上的导出函数 . L, e7 H. w$ w6 g0 o3 c
  #include #include typedef struct Student { char name[20];int age;double scores[32];}Student;typedef struct Class { int number;Student students[126];}Class;extern “C” __declspec(dllexport) int GetClass(Class pClass[50]) + ^( Q& j* a; K7 u% C
  { for(int i=0;i
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Woexam.Com ( 湘ICP备18023104号 )

GMT+8, 2024-5-18 13:08 , Processed in 0.173329 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表