You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
on slide 61 of lesson 2 (sub-theme Pointers), an example C code snippet is presented to illustrate pointer behavior, specifically returning the address of a local variable
int*get_pointer(void) {
inti=42;
return&i;
}
the slide then juxtaposes this with a Go equivalent, implying similar behavior or direct analogy:
funcgetPointer() *int {
variint=42return&i
}
the C code example for get_pointer() that returns the address of a stack-allocated variable int i immediately leads to Undefined Behavior upon dereferencing the returned pointer in main printf("%d\n", *p);