Answers for "define pointer in go"

Go
2

go pointers

&	address of / create pointer
*	dereference pointer
Posted by: Guest on January-12-2021
1

go pointers

func main() {
	i, j := 42, 2701

	p := &i         // point to i
	fmt.Println(*p) // read i through the pointer
	*p = 21         // set i through the pointer
	fmt.Println(i)  // see the new value of i

	p = &j         // point to j
	*p = *p / 37   // divide j through the pointer
	fmt.Println(j) // see the new value of j
}
Posted by: Guest on January-13-2021

Browse Popular Code Answers by Language