Handling stdin in Go

From NovaOrdis Knowledge Base
Revision as of 01:47, 23 August 2023 by Ovidiu (talk | contribs) (→‎Internal)
Jump to navigation Jump to search

Internal

fmt.Scan()

var s string
cnt, err := fmt.Scan(&s)
fmt.Printf("input line: %s, cnt: %d, error: %s\n", s, cnt, err)

fmt.Scanf()

var f float
cnt, err := fmt.Scanf("%f", &f)