请教结构体的问题

fish_snow 2005-02-09 02:54:04

typedef struct//define the phoonbook's number's structure
{
BYTE bPhbNumberLength;
BYTE bPhbNumber[12];
}NUMBER_DATA;
typedef struct//define the result's structure
{
BYTE bPhbName[16];
BYTE bCharSet;
NUMBER_DATA stNumber[3];
}VCARD_TO_PHB_RESULT;

VCARD_TO_PHB_RESULT *stPb;
stPb = (struct VCARD_TO_PHB_RESULT*)malloc(sizeof(struct VCARD_TO_PHB_RESULT));
为什么会出现“VCARD_TO_PHB_RESULT 不能识别“的错误呢?我换成了一般的result也一样是这个问题。
...全文
154 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
fish_snow 2005-02-14
  • 打赏
  • 举报
回复
解决了,是工程的问题。真奇怪,这个visio.net要让我吐血了,多谢大家!
嘿嘿,初来乍到的,还得给大家见个礼哈!^-^
heibaisenlin111 2005-02-10
  • 打赏
  • 举报
回复
#include <stdio.h>
#include <malloc.h>
typedef struct {
int x;
int y;
}position1;
typedef struct {
int x1;
int y1;
position1 a[2];
}position2;
int main()
{ position2 *p;
p=(position2 *)malloc(sizeof(position2));
if (p==0) {printf("warning exit!\n") ;exit(1);}
p->x1=2;p->y1=3;p->a[0].x=4;p->a[1].y=5;
printf("%d %d %d %d\n",p->x1,p->y1,p->a[0].x,p->a[1].y);
}
sky911911 2005-02-10
  • 打赏
  • 举报
回复
#include <stdio.h>
#include <malloc.h>
struct position1{
int x;
int y;
}position11;
struct position2{
int x1;
int y1;
}position22;
int main()
{ struct position2 *p;
p=(struct position2 *)malloc(sizeof(struct position2));
if (p==0) {printf("warning exit!\n") ;exit(1);}
p->x1=2;p->y1=3;position11.x=4;position11.y=5;
printf("%d %d %d %d\n",p->x1,p->y1,position11.x,position11.y);
}
2 3 4 5
这样对了 呵呵
sky911911 2005-02-10
  • 打赏
  • 举报
回复
不好意思 上面的错误太到了 更改中ing。。。。。。。。
sky911911 2005-02-10
  • 打赏
  • 举报
回复
#include <stdio.h>
#include <malloc.h>
struct position1{
int x;
int y;
}position1;
struct position2{
int x1;
int y1;
position1 a[2];
}position2;
int main()
{ positon2 *p;
p=(struct position2 *)malloc(sizeof(struct position2));
if (p==0) {printf("warning exit!\n") exit(1);}
p.x1=2;p.y1=3;p.position1.x=4;p.position1.y=5;
printf("%d %d %d %d\n",p.x1,p.y1,p.position1.x,p.position1.y);
}
我这个为什么提示是 position1 a[2];出问题了呢?
candlelight 2005-02-10
  • 打赏
  • 举报
回复
^_^ 用new申请空间试试看啊
Ph0nix 2005-02-10
  • 打赏
  • 举报
回复
第二次你有没有先拿VCARD_TO_TESULT先定义stPb啊?你把错误消息发上来看看
fish_snow 2005-02-09
  • 打赏
  • 举报
回复
stPb = (struct VCARD_TO_PHB_RESULT*)malloc(sizeof(struct VCARD_TO_PHB_RESULT));

去掉了,可以,呵呵,不过又有新问题了。

不知道为什么,这样申请空间申请不下来,但
stPb = malloc(sizeof(VCARD_TO_PHB_RESULT));
就能申请下来,是强制转换出的问题吗?
sky911911 2005-02-09
  • 打赏
  • 举报
回复
同意楼上的
typedef struct//define the phoonbook's number's structure
{
BYTE bPhbNumberLength;
BYTE bPhbNumber[12];
}NUMBER_DATA;
typedef struct//define the result's structure
{
BYTE bPhbName[16];
BYTE bCharSet;
NUMBER_DATA stNumber[3];
}VCARD_TO_PHB_RESULT;

VCARD_TO_PHB_RESULT *stPb;
stPb = (VCARD_TO_PHB_RESULT*)malloc(sizeof(struct VCARD_TO_PHB_RESULT));
junnyfeng 2005-02-09
  • 打赏
  • 举报
回复
stPb = (VCARD_TO_PHB_RESULT*)malloc(sizeof( VCARD_TO_PHB_RESULT));
junnyfeng 2005-02-09
  • 打赏
  • 举报
回复
同上啊
aniu4586 2005-02-09
  • 打赏
  • 举报
回复
或者你改成
struct NUMBER_DATA
{
BYTE bPhbNumberLength;
BYTE bPhbNumber[12];
};
struct VCARD_TO_PHB_RESULT
{
BYTE bPhbName[16];
BYTE bCharSet;
NUMBER_DATA stNumber[3];
};
哈哈
qinxiaolin 2005-02-09
  • 打赏
  • 举报
回复
stPb = (struct VCARD_TO_PHB_RESULT*)malloc(sizeof(struct VCARD_TO_PHB_RESULT));
去掉里面的 struct  上试试

70,023

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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