Sobes.tech
Junior — Senior

Impact of pointer reassignments inside a function

livecode

Task condition

Determine what output the following program will produce.

func main() {
    v := 5
    p := &v
    println(*p)

    changePointer(p)
    println(*p)
}

func changePointer(p *int) {
    v := 3
    p = &v
}