1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Go言語-fmt.Scan

Posted at

fmt.Scan

プログラミング基本からGoの理解を文字におこして行こうと思います!

fmt.Scan

var input string
fmt.Scan(&input)  //❶fmt.scan(&変数名)でコンソールに文字入力
}

//コンソール
Go  //❷文字列を入力→❸変数inputに入力された値Goが代入

fmt.Scan(&変数名)を使うとコンソールでの入力ができる
入力された値は変数inputに代入

入力の流れ

func main() {
  var input string
fmt.Println("次の単語を入力してください:go") //❶
fmt.Scan(&input)              //❷
fmt.Printf("%sと入力されました", input)   //❸

//コンソール
//❶次の単語を入力してください:go 
//❷go(コンソールで入力)            
//❸goと入力されました

fmt.Scanを使うと入力ができるようになる

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?