acm题的一个runtime error的错误

2025-03-04 21:00:11
推荐回答(4个)
回答1:

兄弟,你malloc出来才需要你去free
char guard[10]; 是局部变量字符数组 不是你malloc出来的
你最后还要 free(guard); 肯定会挂掉的

回答2:

将 free(guard);删去
我查了下MSDN中有
The free function deallocates a memory block (memblock) that was previously allocated by a call to calloc, malloc, or realloc.
即free只能释放用calloc, malloc, realloc等函数分配的内存空间!
char guard[10];
显然guard不是!

回答3:

最后free(guard)去掉

回答4:

free(guard);
这个错了
这是数组,你能free?