Handling stdin in Go: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 15: | Line 15: | ||
cnt, err := fmt.Scanf("%f", &f) | cnt, err := fmt.Scanf("%f", &f) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==<tt>fmt.Scanf()</tt>== | |||
* <tt>[https://golang.org/pkg/fmt/#Scanf fmt.Scanf()]</tt> | |||
==<tt>fmt.Scanln()</tt>== | |||
* <tt>[https://golang.org/pkg/fmt/#Scanln fmt.Scanln()]</tt> | |||
<pre> | |||
var line string | |||
fmt.Scanln(&line) | |||
</pre> |
Revision as of 01:50, 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.Scanf()
fmt.Scanln()
var line string fmt.Scanln(&line)