26. Pointers
Sharing!
Pointers
a := 10
b := &a
fmt.Printf("Value of a is %d \n", a)
fmt.Printf("Address of a is %v\n", &a)
fmt.Printf("Value at pointer location is %v\n", *b)Pointer Type
var intP *int
var floatP *float64
fmt.Println(intP, floatP)Pointer to structure
type location struct {
street string
city string
pincode int
}
myLocation := &location{
street: "Xyz",
city: "Pune",
pincode: 444101,
}
fmt.Printf("I live on %s street, %s city with %d code\n",
myLocation.street, myLocation.city, myLocation.pincode)Sharing Data
Blog Resources
Last updated