STM32f103 C语言查找一个字符串,如果在遍历查找中不打印出字符串,就找不到,但是如果在遍历中打印出遍历的每个字符,就能找到了 这是我的代码,其中 printf 如果注释掉,就找不到 “OK”
```c
for (int i = 0; i < 100; i++)
{
printf("%c %c\r\n", WIFI_recv_buf[i], WIFI_recv_buf[i + 1]);
if (WIFI_recv_buf[i] == 'O' && WIFI_recv_buf[i + 1] == 'K')
{
WIFI_recv_point = 0;
memset(WIFI_recv_buf, 0, sizeof(WIFI_recv_buf));
LOG_I("%s %s!", cmd, ack);
return WIFI_RE_OK;
}
if (strncmp((const char *)(WIFI_recv_buf + i), "ERROR", 5) == 0)
{
LOG_I("RECV》》%s《《", WIFI_recv_buf);
WIFI_recv_point = 0;
memset(WIFI_recv_buf, 0, sizeof(WIFI_recv_buf));
LOG_W("%s ERROR!>>%s", cmd, WIFI_recv_buf);
return WIFI_RE_ER;
}
}
```