Example of Sscan vs Sscanf vs Sscanln from FMT Package
Sscan scans the argument string, storing successive space-separated values into successive arguments. Newlines count as space.
Sscanf scans the argument string, storing successive space-separated values into successive arguments as determined by the format.
Sscanln is similar to Sscan, but stops scanning at a newline and after the final item there must be a newline or EOF.
Example
package main
import (
"fmt"
)
func main(){
var X int
var Y int
fmt.Printf("\nIntital X: %d, Y: %d", X, Y)
fmt.Sscan("100\n200", &X, &Y)
fmt.Printf("\nSscan X: %d, Y: %d", X, Y)
fmt.Sscanf("(10, 20)", "(%d, %d)", &X, &Y)
fmt.Printf("\nSscanf X: %d, Y: %d", X, Y)
fmt.Sscanln("50\n50", &X, &Y)
fmt.Printf("\nSscanln X: %d, Y: %d", X, Y)
}
Output
Intital X: 0, Y: 0
Sscan X: 100, Y: 200
Sscanf X: 10, Y: 20
Sscanln X: 50, Y: 20
Most Helpful This Week
How to declare Interface Type in Go Programming Language
Golang program for implementation of Linked List
Program in Golang to print Pyramid of Numbers
How do you read headers from an HTTP response with an HTTP client in Go?
Golang program to read XML file into struct
How do you handle HTTP server caching in Go?
Go program to find Forward(A) record of a domain
How to convert Boolean Type to String in Go?
Go program to find SRV service record of a domain
Program to print pyramid using numbers