Golang fmt.Sscanf() function example
package fmt
Sscanf scans the argument string, storing successive space-separated values into successive arguments as determined by the format. It returns the number of items successfully parsed.
Golang fmt.Sscanf() function usage example
package main
import "fmt"
func main() {
str := "我的名字是 (my name is) : Golang , I'm 5 years old now"
var name string
var age int
// WARNING : the comma must be separated by a space
// %s , OK
// %s, NOT OK
fmt.Sscanf(str, "我的名字是 (my name is) : %s , I'm %d years old now", &name, &age)
fmt.Printf("%s %d\n", name, age)
}
Output :
Golang 5
Reference :
Advertisement
Something interesting
Tutorials
+25.3k Golang : Get current file path of a file or executable
+22.7k Golang : Round float to precision example
+5.9k Golang : Denco multiplexer example
+30.6k Golang : Remove characters from string example
+36.3k Golang : Convert(cast) int64 to string
+8.1k Golang : Randomize letters from a string example
+12.1k Golang : Decompress zlib file example
+6.2k Golang : Get Hokkien(福建话)/Min-nan(閩南語) Pronounciations
+9.3k Golang : How to get garbage collection data?
+9.1k Golang : Serving HTTP and Websocket from different ports in a program example
+10.3k Golang : Wait and sync.WaitGroup example