誰でもこれで私を助けることができますか?次の構造体があるとします。
typedef struct mystruct{
int data1;
int data2;
}mystruct;
そして、以下のコードを使用して構造体の配列を作成しました:
main(void) {
mystruct **new_mystruct = function();
... need to know the length of new_mystruct here ...
}
mystruct **function(){
... code to determine length of array here ...
mystruct **new_mystruct= malloc(length_of_array * sizeof(mystruct));
... code to fill array here ...
return new_mystruct;
}
関数の実行時に length_of_array が動的に生成されると仮定すると、配列の長さを返す最良の方法は何ですか?
私が理にかなっていることを願っています。前もって感謝します。