亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用 sscanf 忽略字段(%* 被拒絕)

如何使用 sscanf 忽略字段(%* 被拒絕)

Go
神不在的星期二 2021-06-04 17:50:41
我希望在使用 sscanf 處理字符串時忽略特定字段。sscanf 的手冊頁說An optional '*' assignment-suppression character: scanf() reads input as directed by the conversion specification, but discards the input.  No corresponding pointer argument is required, and this specification is not included in the count of successful assignments returned by scanf().嘗試在 Golang 中使用它,忽略第三個字段:if c, err := fmt.Sscanf(str, " %s %d %*d %d ", &iface.Name, &iface.BTx, &iface.BytesRx); err != nil || c != 3 {編譯正常,但在運行時 err 設置為:bad verb %* for integerGolang doco 沒有特別提到 %* 轉換規范,但它確實說,Package fmt implements formatted I/O with functions analogous to C's printf and scanf.這并不表示 %* 沒有實現,所以......我做錯了嗎?或者它只是被悄悄地省略了?...但是,它為什么要編譯?
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 415 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號