I am getting non-numeric type *int error in the example below, why ?
func main() {
count := 0
for {
counting(&count)
}
}
func counting(count *int) {
fmt.Println(count)
count++
}
I am getting non-numeric type *int error in the example below, why ?
func main() {
count := 0
for {
counting(&count)
}
}
func counting(count *int) {
fmt.Println(count)
count++
}
You need to derefence the pointer:
package main
import (
"fmt"
)
func main() {
count := 0
for i:=0; i<10; i++ {
counting(&count)
}
}
func counting(count *int) {
fmt.Println(*count)
*count++
}