Answers for "go fmt.scan"

0

golang fmt.scanln whole line

scanner := bufio.NewScanner(os.Stdin)
if scanner.Scan() {
    line := scanner.Text()
    fmt.Printf("Input was: %qn", line)
}
Posted by: Guest on July-30-2020
0

go fmt.scan

// Golang program to illustrate the usage of
// fmt.Scan() function
 
// Including the main package
package main
 
// Importing fmt
import (
    "fmt"
)
 
// Calling main
func main() {
 
    // Declaring some variables
    var name string
    var alphabet_count int
    var float_value float32
    var bool_value bool
 
    // Calling Scan() function for
    // scanning and reading the input
    // texts given in standard input
    fmt.Scan(&name)
    fmt.Scan(&alphabet_count)
    fmt.Scan(&float_value)
    fmt.Scan(&bool_value)
 
    // Printing the given texts
    fmt.Printf("%s %d %g %t", name,
     alphabet_count, float_value, bool_value)
 
}
Posted by: Guest on January-25-2022

Browse Popular Code Answers by Language