面试题答案
一键面试#include <stdio.h>
#include <stdlib.h>
struct Inner {
int data[100];
};
struct Outer {
struct Inner *inner;
struct Outer *next;
};
void safeFreeOuters(struct Outer **outers, int count) {
for (int i = 0; i < count; i++) {
struct Outer *current = outers[i];
while (current != NULL) {
struct Outer *next = current->next;
if (current->inner != NULL) {
free(current->inner);
}
free(current);
current = next;
}
}
free(outers);
}