unsigned char rxbuf = wdy32提取后面两个字符赋给unsigned int tempc语言
你可以使用sscanf函数来提取后面两个字符,并将其赋给unsigned int类型的变量temp。以下是一个示例代码:
#include <stdio.h>
int main() {
unsigned char *rxbuf = "wdy:32";
unsigned int temp;
sscanf(rxbuf, "wdy:%2u", &temp);
printf("temp: %u\n", temp);
return 0;
}
运行以上代码,你将会得到输出结果:
temp: 32
在这个示例中,我们使用了sscanf函数来从字符串rxbuf中提取后面两个字符,并使用"%2u"格式说明符来指定提取的字符个数,将提取的结果保存在temp变量中。最后,我们使用printf函数来输出temp的值。
原文地址: https://www.cveoy.top/t/topic/iBzW 著作权归作者所有。请勿转载和采集!