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.
我正在动态分配一个双指针(char **pointer),一些方法稍后不再知道有关长度的信息。
有没有一种干净的方法可以在不知道指针数组长度的情况下释放“指针数组”和“字符数组”?
技术上是有办法的。
如果分配一个额外的指针,并将最后一个指针设置为NULL,则可以释放所有双精度数组,然后释放双精度数组数组,直到达到NULL。这与字符串的原理相似。
NULL
不过,您可能不需要这个。
我只能想到使用数组的索引 0 作为它的总长度。