对unsigned char类型数据的指定位置0或置1操作

void bit_set(unsigned char *p_data,unsigned char position,int flag)
{
	int i = 0;
	if(1 == flag)
	{
		*p_data |= (1<<(position-1));
	}
	else if(0 == flag)
	{
		*p_data &= ~(1<<(position-1));
	}
}

p_data是要修改的数据,position是要指定的位,flag是0/1

猜你喜欢

转载自blog.csdn.net/m0_38032942/article/details/80770054
今日推荐