为了账号安全,请及时绑定邮箱和手机立即绑定

如下,当i=0时,m_cbHandCardData[0][14]的所有元素不都为0吗?

如下,当i=0时,m_cbHandCardData[0][14]的所有元素不都为0吗?

猛跑小猪 2022-05-26 19:15:30
const BYTE CGameLogic::m_cbCardData[108]={0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D, //方块 A - K0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D, //梅花 A - K0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D, //红桃 A - K0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D, //黑桃 A - K0x4E,0x4F,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D, //方块 A - K0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D, //梅花 A - K0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D, //红桃 A - K0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D, //黑桃 A - K0x4E,0x4F,}//混乱扑克VOID RandCardList(BYTE cbCardBuffer[], BYTE cbBufferCount){//混乱准备BYTE cbCardData[CountArray(m_cbCardData)];CopyMemory(cbCardData,m_cbCardData,sizeof(m_cbCardData));//混乱扑克BYTE cbRandCount=0,cbPosition=0;do{cbPosition=rand()%(cbBufferCount-cbRandCount);cbCardBuffer[cbRandCount++]=cbCardData[cbPosition];cbCardData[cbPosition]=cbCardData[cbBufferCount-cbRandCount];} while (cbRandCount<cbBufferCount);return;}BYTE cbRandCard[108];BYTE m_cbHandCardData[4][27];RandCardList(cbRandCard,CountArray(cbRandCard));for (WORD i=0;i<4;i++){m_cbHandCardCount[i]=MAX_COUNT;CopyMemory(&m_cbHandCardData[i],&cbRandCard[i*m_cbHandCardCount[i]],sizeof(BYTE)*m_cbHandCardCount[i]);}哪位C++高手能详细分析一下CopyMemory()函数是怎样把数组cbRandCard[]的内容复制到m_cbHandCardData[]数组中的,当i=0时,m_cbHandCardData[0][14]的所有元素不都为0吗?可是我不是想知道函数CopyMemory()的作用,我是想知道当i=0,1,2,3,时cbRandCard[i*m_cbHandCardCount[i]以及m_cbHandCardData[i]的变化情况
查看完整描述

1 回答

?
哈士奇WWW

TA贡献1799条经验 获得超6个赞

CopyMemory(cbCardData,m_cbCardData,sizeof(m_cbCardData));
意思就是将数据从m_cbCardData复制到cbCardData中,数据量为m_cbCardData所占的空间大小。
您说的那个循环里面它会COPY到目标数组中MAX_COUNT个字节的数据,不过貌似这个代码不全,所以MAX_COUNT我也就无从知晓了:)

查看完整回答
反对 回复 2022-05-30
  • 1 回答
  • 0 关注
  • 148 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信