#define Temp_str "\r\n+QIURC: \"recv\",2,332\r\n**1111111aa111111##\r\n"
unsigned int Num1;
unsigned int Num2;
char str_1[30 + 1] = {0};
char str_2[20 + 1] = {0};
int main(void)
{
hw_init(); //硬件初始化
sscanf(Temp_str, "%[^,],%d,%d\r\n%[^\r]\r\n", str_1, &Num1, &Num2, str_2);
Usart1Printf("Num1=%d Num2=%d str_1=%s str_2=%s\n", Num1, Num2, str_1, str_2);
}
打印结果:
Num1=2 Num2=332 str_1=
+QIURC: "recv" str_2=**1111111aa111111##