We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
关于这点【不能将函数内的指向局部变量的指针作为返回值, 函数结束指向空间会被释放】有疑问,示例如下:
package main import ( "fmt" ) func f() *int { n := 100 fmt.Println("1:", &n, n) return &n } func main() { n := f() fmt.Println("2:", n, *n) (*n) = 99 fmt.Println("3:", n, *n) }
输出:
1: 0x140000aa008 100 2: 0x140000aa008 100 3: 0x140000aa008 99
The text was updated successfully, but these errors were encountered:
No branches or pull requests
关于这点【不能将函数内的指向局部变量的指针作为返回值, 函数结束指向空间会被释放】有疑问,示例如下:
输出:
The text was updated successfully, but these errors were encountered: