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
+31.5k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions
+5.2k Golang : Customize scanner.Scanner to treat dash as part of identifier
+8.9k Golang : Find network service name from given port and protocol
+5.9k Golang : Extract unicode string from another unicode string example
+8.3k Golang : Check if integer is power of four example
+39.2k Golang : How to read CSV file
+5.5k Golang : Display advertisement images or strings on random order
+8.2k Golang : Find relative luminance or color brightness
+10.4k Golang : Simple Jawi(Yawi) to Rumi(Latin/Romanize) converter
+10.6k Golang : Simple File Server
+25.6k Golang : convert rune to integer value
+13.1k Golang : List objects in AWS S3 bucket