c語言 結構體巢狀一級指標

2021-10-06 06:35:43 字數 1060 閱讀 3915

這裡用支了二級指標

void

test()

執行

name:name_1 age:

100name:name_2 age:

101name:name_3 age:

102name:name_1的記憶體被釋放!

name:name_2的記憶體被釋放!

name:name_3的記憶體被釋放!

;//分配記憶體

struct person*

*allocatespace()

return temp;

}//列印

void

printperson

(struct person *

*person)

for(

int i =

0; i <3;

++i)

}//釋放記憶體

void

freespace

(struct person *

*person)

for(

int i =

0; i <3;

++i)

if(person[i]

->name !=

null

)free

(person[i]);

person[i]

=null;}

free

(person)

; person =

null;}

void

test()

intmain()

c語言——結構體巢狀二級指

結構體中套一級指標

define crt secure no warnings include include include typedef struct teacher teacher 陣列做函式引數會退化為指標 void printteacher teacher array,int num void sortte...

C語言提高38 結構體套一級指標

結構體陣列 3 輸入老師年齡 排序 include include include includetypedef struct teacher teacher void printfteacher teacher array,int num void sortteacher teacher arra...

c語言 結構體巢狀二級指標

如果乙個結構體內巢狀二級指標了二級指標,這裡的students為二級指標,也對應了一對多的關係,乙個老師,多個學生。struct teacher 我們知道,二級指標指向一級指標的位址,指標指向二級指標的位址 void test 列印老師及其學生資訊 printteachers teachers 釋放...