How to use pointers in Go

1 Answer

0 votes
package main

import "fmt"

func main() {
	a, b := 123, 98

	p := &a         
	fmt.Println(*p) 
	*p = 3         
	fmt.Println(a) 

	p = &b         
	*p = *p * 2
	fmt.Println(b) 
}



/*
run:

123
3
196

*/

 



answered Feb 25, 2020 by avibootz

Related questions

1 answer 176 views
176 views asked Aug 25, 2020 by avibootz
2 answers 262 views
262 views asked Aug 9, 2020 by avibootz
4 answers 38 views
1 answer 99 views
99 views asked Jul 11, 2025 by avibootz
...