Golang fmt.Sscanln() function example
package fmt
Sscanln is similar to Sscan, but stops scanning at a newline and after the final item there must be a newline or EOF.
Golang fmt.Sscanln() function usage example
package main
import "fmt"
func main() {
answers := "1 0 \n 8"
var a, b, c int
// will stop scanning at \n
fmt.Sscanln(answers, &a, &b, &c)
fmt.Println(a, b, c)
// for comparison
answers = "1 0 8"
fmt.Sscanln(answers, &a, &b, &c)
fmt.Println(a, b, c)
}
Output :
1 0 0 (c was not 'scanned')
1 0 8
Reference :
Advertisement
Something interesting
Tutorials
+5.6k Javascript : How to refresh page with JQuery ?
+13.9k Golang : How to check if a file is hidden?
+7.9k Golang : Trim everything onward after a word
+13.8k Golang : unknown escape sequence error
+5.2k Golang : PGX CopyFrom to insert rows into Postgres database
+20.6k Nginx + FastCGI + Go Setup.
+9.2k Golang : does not implement flag.Value (missing Set method)
+28.6k Golang : Read, Write(Create) and Delete Cookie example
+7.7k Golang : Mapping Iban to Dunging alphabets
+9.9k Golang : Sort and reverse sort a slice of integers
+5.3k Swift : Convert string array to array example
+21.1k Golang : Sort and reverse sort a slice of strings