unsigned char rxbuf = wdy32提取rxbuf 后面的值32赋给unsigned int tempc语言
你可以使用sscanf函数来提取字符串中的值,并将其赋给temp变量。下面是一个示例代码:
#include <stdio.h>
int main() {
unsigned char *rxbuf = "wdy:32";
unsigned int temp;
sscanf(rxbuf, "wdy:%u", &temp);
printf("temp = %u\n", temp);
return 0;
}
这个代码中,sscanf函数的格式化字符串"wdy:%u"表示匹配以"wdy:"开头,后面跟着一个无符号整数的字符串。%u指示将提取的值存储到temp变量中。
原文地址: https://www.cveoy.top/t/topic/iBzQ 著作权归作者所有。请勿转载和采集!