【C++】在子函數中調用malloc申請內存的方法

在函數體內申請內存。ios 解決辦法 1. 在函數體內申請完內存後,將地址返回 int* test(){ int *p = (int*)malloc(sizeof(int)*100); return p; } 2. 用二級指針修改指針指向地址 void test(int **ptr){ *ptr = (int*)malloc(sizeof(int)*100); } 易錯點 函數體傳參爲1級指
相關文章
相關標籤/搜索