In Go language,
fmt package implements formatted I/O with functions analogous to C's printf() and scanf() function. The
fmt.Sscanf() function in Go language scans the specified string and stores the successive space-separated values into successive arguments as determined by the format. Moreover, this function is defined under the fmt package. Here, you need to import the "fmt" package in order to use these functions.
Syntax:
func Sscanf(str string, format string, a ...interface{}) (n int, err error)
Parameters: This function accepts three parameters which are illustrated below:
- str string: This parameter contains the specified text which is going to be scanned.
- format string: This parameter is the different types of format for each elements of the specified string.
- a ...interface{}: This parameter receives each elements of the string.
Returns: It returns the number of items successfully parsed.
Example 1:
Output:
2: GFG, 3
Example 2:
Output:
4: GeeksforGeeks, 13, 6.7, true