Logo

Programming-Idioms

History of Idiom 120 > diff from v28 to v29

Edit summary for version 29 by programming-idioms.org:
New Go implementation by user [programming-idioms.org]

Version 28

2018-06-24, 08:03:28

Version 29

2018-06-24, 08:08:11

Idiom #120 Read integer from stdin

Read an integer value from the standard input into variable n.

Idiom #120 Read integer from stdin

Read an integer value from the standard input into variable n.

Code
_, err := fmt.Scanf("%d", &n)
Comments bubble
This parses decimal numbers (even if they have a trailing 0)
Doc URL
https://golang.org/pkg/fmt/#Scanf
Demo URL
https://play.golang.org/p/mw1N0O5lgQp