Can fscanf() read whitespace?

后端 未结 6 1839
野趣味
野趣味 2020-12-09 00:29

I\'ve already got some code to read a text file using fscanf(), and now I need it modified so that fields that were previously whitespace-free need to allow whi

6条回答
  •  旧巷少年郎
    2020-12-09 01:08

    You're running up against the limits of what the *scanf family is good for. With fairly minimal changes you could try using the string-scanning modules from Dave Hanson's C Interfaces and Implementations. This stuff is a retrofit from the programming language Icon, an extremely simple and powerful string-processing language which Hanson and others worked on at Arizona. The departure from sscanf won't be too severe, and it is simpler, easier to work with, and more powerful than regular expressions. The only down side is that the code is a little hard to follow without the book—but if you do much C programming, the book is well worth having.

提交回复
热议问题