这里假设u8 rxbuf = wdy32提取字符串后面的内容赋给unsigned int tempc语言
可以使用sscanf函数来提取字符串中的内容,并将其赋值给unsigned int类型的变量temp。
具体代码如下:
#include<stdio.h>
int main() {
unsigned int temp;
u8 *rxbuf = "wdy:32";
sscanf(rxbuf, "wdy:%u", &temp);
printf("temp = %u\n", temp);
return 0;
}
输出结果为:
temp = 32
这样就将字符串中":"后面的内容提取出来,并赋值给了unsigned int类型的变量temp。
原文地址: https://www.cveoy.top/t/topic/iBzC 著作权归作者所有。请勿转载和采集!