#include <iostream>
#define RTA_DATA(rta) ((crypto_attr_type*)(((char*)(rta)) + 20))
struct test{
int first;
int second;
};
int test_ptr(struct test** ptr){
struct test* new_node = nullptr;
new_node = (struct test*)malloc(sizeof (test));
new_node->first = 1;
new_node->second = 3;
*ptr = new_node;
return 0;
}
int main(){
struct test* hh = nullptr;
test_ptr(&hh);
std::cout << hh[0].first << std::endl;
std::cout << hh[0].second << std::endl;
free(hh);
hh = nullptr;
}
结构体中二级指针的赋值和释放
最新推荐文章于 2022-03-14 16:49:01 发布