
获取 char数组的指针
请大神帮忙,我想发送这个IP地址(或者串口输出),但是怎么才能得到这个charudp_remote_ip[4]的指针呢?因为sdk中的sent(,,)方法只收uint8*...
请大神帮忙,我想发送这个IP地址(或者串口输出),但是怎么才能得到这个char udp_remote_ip[4]的指针呢?因为sdk中的sent(,,)方法只收uint8 *psent指针类型。const char udp_remote_ip[4]={premot->remote_ip[0],premot->remote_ip[1],premot->remote_ip[2],premot->remote_ip[3]};
char *inIp;
espconn_sent(pesp_conn, inIp, os_strlen(inIp)); 展开
char *inIp;
espconn_sent(pesp_conn, inIp, os_strlen(inIp)); 展开
1个回答
展开全部
char和uint8是可以通用的.
而数组名本身就可以做指针用.
所以 直接用udp_remote_ip就好了.
espconn_sent(pesp_conn, udp_remote_ip, sizeof(udp_remote_ip));
而数组名本身就可以做指针用.
所以 直接用udp_remote_ip就好了.
espconn_sent(pesp_conn, udp_remote_ip, sizeof(udp_remote_ip));
追问
不行的 这样编译会报错,只能用指针error: passing argument 2 of 'espconn sent' discards 'const' qualifier from
pointer target type [-Werror
追答
加个强制转换. espconn_sent(pesp_conn, (uint8 *)udp_remote_ip, sizeof(udp_remote_ip));
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询