在实现sscanf()函数中,先读前五个字符串,然后忽略一个不读(%*就是忽略的意思),然后继续读下去,后面都是对的,为什么第一个就是读不到GD002呢?感谢帮忙求解呀~
/*************************************************************************
> File Name: sscanf.c
> Author: WangDengtao
> Mail: 1799055460@qq.com
> Created Time: 2022年10月14日 星期五 23时14分32秒
************************************************************************/
#include<stdio.h>
int main(int argc, char *argv[])
{
char device[15];
char date[15];
char time[15];
char temper[10];
char buf[512] = "GD002/2022-10-11/18:52:15/35.4941摄氏度";
int ret = sscanf(buf, "%05s %*01s %10s %*01s %08s %*01s %s", device, date, time, temper);
printf("device:%s\n", device);
printf("data:%s\n", date);
printf("time:%s\n", time);
printf("temper:%s\n", temper);
return 0;
}