+ 1

What's wrong in this code???

package main import "fmt" //passing pointer to function /*func age(num int){ num=25 } func age_year(year*int){ *year=2 } func main() { x:=8 age(x) fmt.Println(x) age_year (&x) fmt. Println (x) }*/ func change(value int){ value=35 } func change_ptr(ptr *int){ *ptr=87 } func main(){ x:=54 change(x) fmt. Println(x) change_ptr (&x) fmt. Println (x) }

5th Jun 2021, 3:25 PM
Sayyad Faujiya
Sayyad Faujiya - avatar
2 Answers
+ 2
Thank you
5th Jun 2021, 3:42 PM
Sayyad Faujiya
Sayyad Faujiya - avatar
+ 1
What's wrong? Both codes are working.
5th Jun 2021, 3:33 PM
Solo
Solo - avatar