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 :
Advertisement
Something interesting
Tutorials
+16.3k Golang : convert string or integer to big.Int type
+8.9k Golang : Find network service name from given port and protocol
+4.7k MariaDB/MySQL : Form select statement or search query with Chinese characters
+11.3k Golang : Fix fmt.Scanf() on Windows will scan input twice problem
+5k Golang : Constant and variable names in native language
+28.6k Get file path of temporary file in Go
+13k Golang : Get terminal width and height example
+6.5k Golang : Convert an executable file into []byte example
+21.2k Golang : Convert(cast) string to rune and back to string example
+36.5k Golang : Validate IP address
+8.9k Golang : What is the default port number for connecting to MySQL/MariaDB database ?
+22.7k Golang : Set and Get HTTP request headers example