Created
December 8, 2016 23:59
-
-
Save hygull/7d7ea0dc03ab51fceb673d2e3bad989f to your computer and use it in GitHub Desktop.
strconv (convert a string to an int) created by hygull - https://repl.it/Eg5v/0
This file contains 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
/* | |
@Date of creation : 05 Dec 2016. | |
@Aim of program : To convert a string of digits to an integer. | |
@Coded by : Rishikesh Agrawani. | |
*/ | |
package main | |
import "fmt" | |
import "strconv" | |
func main(){ | |
str:="1234" | |
//Printing the type of str | |
fmt.Printf("\n%T",str) | |
//Lets convert this string to an integer | |
n,err:=strconv.Atoi(str) | |
if err!=nil{ | |
fmt.Println("You are not providing a valid string with digits") | |
} | |
fmt.Println("\nSuccessful conversion of a string to an integer") | |
fmt.Printf("%T",n) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment