Sscanf thinks that the string ends when it encounters carriage return and line feed. How can it ignore these carriage return and line feed and continue to search the whole string?

shift0ogg 2021-08-10 13:45:44 阅读数:278

本文一共[544]字,预计阅读时长:1分钟~
sscanf thinks string ends encounters
sscanf When a carriage return line feed is encountered, it is considered that the string ends , How to make it ignore these carriage returns and continue to search the whole string ? sscanf Space encountered continue ?
 1 #include <stdio.h>
2 #include <stdlib.h>
3
4
5
6 char *c = "/o-ran-fm:alarm-notif/fault-id=(19)1 002";
7
8
9 int main(int argc, char const *argv[])
10 {
11 char k[128] = {0};
12 char v[128] = {0};
13 int t = -1;
14
15 sscanf(c, "%[^=]=(%d)%[^\n]", k, &t, v); // Continue to match when encountering spaces
16
17 printf("k=%s\r\n", k);
18 printf("v=%s\r\n", v);
19 printf("t=%d\r\n", t);
20
21 return 0;
22 }
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.

 

 
 
 
 
版权声明:本文为[shift0ogg]所创,转载请带上原文链接,感谢。 https://car.inotgo.com/2021/08/20210810134049320Y.html