Handling stdin in Go: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 3: Line 3:
* [[Go Strings]]
* [[Go Strings]]
* [[Go Package fmt|<tt>fmt</tt> Package]]
* [[Go Package fmt|<tt>fmt</tt> Package]]
=Handling <tt>stdin</tt> with <tt>fmt</tt> Functions=


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

Revision as of 01:49, 23 August 2023

Internal

Handling stdin with fmt Functions

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)