why malloc doesnot work in my c program?
This question already has an answer here:
books
is a pointer, who's size is 4. You can't read the size of your dynamically created "array".
You'll see that malloc works, when it doesn't return NULL.
它打印4,因为这是books
的大小(即指针的大小)。
替代方法:你可以使用一个struct BOOK数组,即struct BOOK books [5000];
链接地址: http://www.djcxy.com/p/28436.html上一篇: 什么是动态铸造的一些“很好用”的例子?