我有一阵.,出于我印刷这一阵列时的任何原因,在最后有一个零点,从而导致该守则最终逐字印出民族解放军。
我是否可以删除最后的记忆层?
For example:
typedef struct
{
char *name;
} B;
typedef struct
{
B *var;
} A;
int main() {
int num = 5; //for example
A *foo = malloc(sizeof(A));
B *bar = malloc(num * sizeof(B));
for (int i = 0; i < num; i++) {
bar[i] = *create_b(&bar[i]); // some function that works.
}
foo->var = bar;
while (foo->var != NULL) {
printf("This is %s
",foo->var->name);
foo->var++;
}
}
一切物品都只印制了罚款,但休息时间结束时不想要印刷。 类似:
This is A
This is B
This is C
This is D
This is F
This is
显然,该阵列只有5个元素,最后1个没有印刷。