Handling stdin in Go: Difference between revisions
Jump to navigation
Jump to search
Line 18: | Line 18: | ||
==<tt>fmt.Scanln()</tt>== | ==<tt>fmt.Scanln()</tt>== | ||
{{External|https://golang.org/pkg/fmt/#Scanln}} | |||
<pre> | <pre> |
Revision as of 01:56, 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)
fmt.Scanln()
var line string fmt.Scanln(&line)