【c语言】指针的指针使用方法

指针的指针一般用法是外部人申明,传入另一个函数以后由这个函数申请空间,但是需要注意的是,要在传入之前给这个指针的指针初始化。

例如


#include<stdio.h>

typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef struct
{
	u16 value_handle;
	u8 offset;
	u8 *data;
	u16 len;
} ble_gatts_write_t;

typedef struct
{
	u16 value_handle;
	u8 offset;
	u8 **data;
	u16 *len;
} ble_gatts_read_t;
typedef struct ble_gatts_evt_param{
	u16 conn_handle;
	union
	{
		ble_gatts_write_t write;
		ble_gatts_read_t read;
	};
}ble_gatts_evt_param_t;


void ble_cae_gatts_callback(ble_gatts_evt_param_t *param){
	printf("ble_cae_gatts_callback enter\n");
	u8 *read_data = NULL;
	u16 read_data_len = 3;
	read_data = (u8 *)malloc(3);
	if(NULL == read_data){
		printf("11111111111111111111111");
		return ;
	}
	printf("ble_cae_gatts_callback 1\n");
	read_data[0] = 0x32;
	read_data[1] = 0xff;
	read_data[2] = 0x00; 
	printf("ble_cae_gatts_callback 2\n");
	*param->read.data = read_data;
	printf("ble_cae_g
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值