C语言中,通过指针给结构体中的变量赋值

typedef struct Mech_Para//
{	
int32_t	P001_TipBoxX;
int32_t	P002_TipBoxY;
int32_t	P003_TipBoxZ;
int32_t	P004_IntervalX;
int32_t	P005_IntervalY;
int32_t	P006_TipBuckleX;
int32_t	P007_TipBuckleY;
int32_t	P008_TipBuckleZ;
int32_t	P009_XXXX;
int32_t	P010_XXXX;
}
Mech_Para 		My_MechPara;
Control_Para 	My_Control_Para;
BuiltIn_Para	My_BuiltIn_Para;
Mech_Para 		*My_MechPara1 = &My_MechPara;//结构体指针
Control_Para 	*My_Control_Para1 = &My_Control_Para;
BuiltIn_Para	*My_BuiltIn_Para1 = &My_BuiltIn_Para;
for(temp_Count111 = 1,temp_Count222 = 1;temp_Count111 < 120;temp_Count111++)//My_MechPara
	{
		/*ÒÔϲÙ×÷Ï൱ÓÚ
		temp_Count_temp1 = System_Param_Array[temp_Count111++]<<16;  
		My_MechPara.P001_TipBoxX = (int32_t)(temp_Count_temp1 + System_Param_Array[temp_Count111++]);
		*/
		temp_Count_temp1 = System_Param_Array[temp_Count222];
		temp_Count222++;
		if(temp_Count111 < 80)
		{			
			*((int32_t *)(My_MechPara1) + temp_Count111-1) = temp_Count_temp1 + System_Param_Array[temp_Count222];//My_MechPara1			
		}
		else if((temp_Count111 >= 80)&&(temp_Count111 < 100))
		{
			*((int32_t *)(My_Control_Para1) + temp_Count111-1) = temp_Count_temp1 + System_Param_Array[temp_Count222];//My_Control_Para
		}
		else if((temp_Count111 >= 100)&&(temp_Count111 < 120))
		{
			*((int32_t *)(My_BuiltIn_Para1) + temp_Count111-1) = temp_Count_temp1 + System_Param_Array[temp_Count222];//My_BuiltIn_Para
		}
		temp_Count222++;
	}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值