打印

结构指针的疑问

[复制链接]
1276|8
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
supernan|  楼主 | 2011-8-25 18:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
unsigned char FAT32_Buffer[512];
struct FAT_Item               
{
unsigned char Item[4];
};


struct FAT32_FAT
{
struct FAT_Item Items[128];  
};

void ******(unsigned long Curr_cluster)
{
   struct FAT_Item  *pItem;
   struct FAT32_FAT *pFat;
   pFat=(struct FAT32_FAT *)(FAT32_Buffer);//这样写没问题
   pItem=&(pFat->Items[Curr_cluster%128]);//这样写没问题
   但是这样写:
   pItem=&((struct FAT32_FAT *)(FAT32_Buffer)->Items[Curr_cluster%128]);//这样写为啥就会出现错误呢
}
沙发
栩栩如生| | 2011-8-25 19:01 | 只看该作者
直接用个二维数组代替

使用特权

评论回复
板凳
司徒老鹰| | 2011-8-25 19:06 | 只看该作者
把有问题的那句改成
pItem=&(((struct FAT32_FAT *)(FAT32_Buffer))->Items[Curr_cluster%128]);

使用特权

评论回复
地板
zwll| | 2011-8-25 19:29 | 只看该作者
嗯,优先级问题

使用特权

评论回复
5
juventus9554| | 2011-8-25 19:34 | 只看该作者
优先级的问题,如楼上用()修饰一下就OK了

使用特权

评论回复
6
supernan|  楼主 | 2011-8-25 21:04 | 只看该作者
谢谢大家了

使用特权

评论回复
7
supernan|  楼主 | 2011-8-25 21:26 | 只看该作者
结贴光荣

使用特权

评论回复
8
金鱼木鱼| | 2011-9-6 00:01 | 只看该作者
经验啊这就是

使用特权

评论回复
9
supernan|  楼主 | 2011-9-8 09:26 | 只看该作者
是啊,我还是个菜鸟

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

730

主题

10412

帖子

6

粉丝