VOOZH about

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

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


  • Courses
  • Tutorials
  • Interview Prep

fmt.Scan() Function in Golang With Examples

Last Updated : 28 Apr, 2025

In Go language, fmt package implements formatted I/O with functions analogous to C's printf() and scanf() function. The fmt.Scan() function in Go language scans the input texts which is given in the standard input, reads from there and stores the successive space-separated values into successive arguments. 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 Scan(a ...interface{}) (n int, err error)


Here, "a ...interface{}" receives each type of the given texts.
Returns: It returns the number of items successfully scanned.
 

Example 1: 

Input: 
 

GFG 3


Output: 
 

The word GFG containing 3 number of alphabets.


Example 2:
 

Input: 
 

GeeksforGeeks 13 6.789 true


Output: 
 

GeeksforGeeks 13 6.789 true


 

Comment
Article Tags:

Explore