41 lines
726 B
Go
41 lines
726 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
func main() {
|
|
// var variable int = 30
|
|
// var pointer *int = &variable
|
|
|
|
// fmt.Printf("Type of pointer %T\n",pointer)
|
|
// fmt.Printf("Value of pointer %v\n",pointer)
|
|
|
|
// secondPtr := &pointer
|
|
// fmt.Println("Pointer to pointer",secondPtr)
|
|
|
|
|
|
// zeroPtr := new(int)
|
|
// *zeroPtr += 40
|
|
// fmt.Println("Address is ",*zeroPtr)
|
|
|
|
|
|
// a := 10
|
|
// c := a
|
|
// b := &a
|
|
// *b += 2
|
|
|
|
// c++
|
|
// fmt.Printf("Val of A is %d and val of C is %d\n",a, c)
|
|
// fmt.Printf("Val of A after changing ref is %d",a)
|
|
|
|
sample := 1
|
|
// samplePtr := &sample
|
|
fmt.Println("Sample val is",sample)
|
|
kek(sample)
|
|
fmt.Println("Sample val is",sample)
|
|
|
|
}
|
|
|
|
func kek(val int) {
|
|
fmt.Println("Val of val is",val)
|
|
val += 100
|
|
} |