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 ?
+4.7k Golang : How to pass data between controllers with JSON Web Token
+19.1k Golang : When to use public and private identifier(variable) and how to make the identifier public or private?
+9.6k Golang : Copy map(hash table) example
+14.6k Golang : Execute function at intervals or after some delay
+5.9k Golang : Use NLP to get sentences for each paragraph example
+11k Golang : Create Temporary File
+8.9k Golang : Gaussian blur on image and camera video feed examples
+9.1k Golang : io.Reader causing panic: runtime error: invalid memory address or nil pointer dereference
+32.7k Golang : Regular Expression for alphanumeric and underscore
+25.3k Golang : Convert uint value to string type
+10.6k Golang : Resolve domain name to IP4 and IP6 addresses.