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 *toParseStr = (char*)malloc(10);有人有想法么?
char *toParseStr = (char*)malloc(10);
这里没有取消引用,而是将malloc返回值转换为char *. 演员表不是必需的,甚至应该避免。
malloc
char *
要知道为什么应该避免演员表:
http://c-faq.com/malloc/mallocnocast.html
malloc 返回一个 void*,因此在某些情况下需要强制转换以防止编译错误