Golang fmt.Sscan() function example

package fmt

Sscan scans the argument string, storing successive space-separated values into successive arguments. Newlines count as space. It returns the number of items successfully scanned. If that is less than the number of arguments, err will report why.

Golang fmt.Sscan() function usage example

 package main

 import "fmt"

 func main() {

 answers := "1 0 8"

 var a, b, c int

 fmt.Sscan(answers, &a, &b, &c)

 fmt.Println(a, b, c)
 }

Output :

1 0 8

Reference :

http://golang.org/pkg/fmt/#Sscan

Advertisement