Handling stdin in Go: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 2: Line 2:
* [[Go_Code_Examples#Code_Examples|Go Code Examples]]
* [[Go_Code_Examples#Code_Examples|Go Code Examples]]
* [[Go Strings]]
* [[Go Strings]]
* [[Go Package fmt|<tt>fmt</tt> Package]]


=<tt>fmt.Scan()</tt>=
=<tt>fmt.Scan()</tt>=

Revision as of 01:47, 23 August 2023

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)