Commit 2bb91e09 authored by Lehner Florian's avatar Lehner Florian Committed by Rob Pike

fmt: add example Sscanf

Updates golang/go#27554.

Change-Id: I2bf3d57ebeeb5dd50beffbc643a4ad10287b2c1e
GitHub-Last-Rev: 4ffae55b4b2ca9d9b2a5b2b6dcef14ce43d83544
GitHub-Pull-Request: golang/go#27954
Reviewed-on: https://go-review.googlesource.com/c/138837Reviewed-by: default avatarRob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 46cf91a7
......@@ -63,6 +63,19 @@ func ExampleFscanln() {
// 3: ken, 271828, 3.141590
}
func ExampleSscanf() {
var name string
var age int
n, err := fmt.Sscanf("Kim is 22 years old", "%s is %d years old", &name, &age)
if err != nil {
panic(err)
}
fmt.Printf("%d: %s, %d\n", n, name, age)
// Output:
// 2: Kim, 22
}
func ExamplePrint() {
const name, age = "Kim", 22
fmt.Print(name, " is ", age, " years old.\n")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment