Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在函数中定义了一个静态变量。 v 可以在该函数之外破坏它的内存吗?
如果您在谈论 C,那么不,您不能“破坏它的内存”——只要您的程序正在运行,您所有的静态变量就会一直存在。
“破坏它的记忆”是什么意思?
如果您的意思是“释放”内存,答案是否定的。
如果您的意思是覆盖它,答案是肯定的(可以将指向变量的指针提供给“拥有”它的函数之外的东西,或者一个常见的错误可能会破坏内存)。