VOOZH about

URL: https://www.geeksforgeeks.org/go-language/fmt-fscanf-function-in-golang-with-examples/

⇱ fmt.Fscanf() Function in Golang With Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

fmt.Fscanf() Function in Golang With Examples

Last Updated : 5 May, 2020
In Go language, fmt package implements formatted I/O with functions analogous to C's printf() and scanf() function. The fmt.Fscanf() function in Go language scans the specified text, read from r and then stores the successive space-separated values into successive arguments as determined by the format. Here newlines in the input must match newlines in 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 Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error)
Parameters: This function accepts three parameters which are illustrated below:
  • r io.Reader: This parameter contains the scanned specified texts.
  • format string: This parameter contains different formats for receiving the elements.
  • a ...interface{}: This parameter is the specified variable for each elements.
Returns: It returns the number of items successfully parsed. Example 1: Output:
10 false GFG
3
Example 2: Output:
46 true 3.4 GeeksforGeeks
4
Comment
Article Tags:

Explore