Created
August 13, 2023 08:22
-
-
Save basicmag/67ac852f2876bdc212446ea0c08d7171 to your computer and use it in GitHub Desktop.
Go言語: fmt.Sscanfで文字列からintに変換する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Go言語 必読本 Essential Go | |
| // https://www.amazon.co.jp/dp/B0CF53VMYB | |
| // | |
| // Go言語: fmt.Sscanfで文字列からintに変換する | |
| package main | |
| import ( | |
| "fmt" | |
| "log" | |
| ) | |
| func main() { | |
| s := "348" | |
| var i int | |
| _, err := fmt.Sscanf(s, "%d", &i) | |
| if err != nil { | |
| log.Fatalf("fmt.Sscanf failed with '%s'\n", err) | |
| } | |
| fmt.Printf("i1: %d\n", i) | |
| } | |
| // Go言語 必読本 Essential Go | |
| // https://www.amazon.co.jp/dp/B0CF53VMYB | |
| // | |
| // Essential Go | |
| // https://www.programming-books.io/essential/go/ | |
| // By Krzysztof Kowalczyk | |
| // | |
| // Content is licensed under Creative Commons Attribution-ShareAlike 3.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment