C using scanf() for | delimited string

后端 未结 3 883
小蘑菇
小蘑菇 2021-01-26 12:04

I want to input a few strings then two integers. Whilst the strings are separated by \'|\', the integers are kept apart by a \'.\'.

Looking around online I have seen s

3条回答
  •  渐次进展
    2021-01-26 12:13

    You must use either [] or s construct, but not both and your format string must incluse the separators.

    So you should write something like :

    sscanf(str, "%[^|]|%[^|]|...",...) 
    

提交回复
热议问题