サイズの異なる構造体の静的配列がいくつかあります。これらの配列にデータを入力する一般化された関数を作成したいと思います。特定の配列にデータを入力して、この関数のパラメーターにします。それを行うための最良の方法は何ですか?(静的配列を回避することを除けば、残念ながらそれらは仕方がありません)。
(の関連ビット)コード:
typedef struct{
char ip[IP_LEN+1];
char netmask[IP_LEN+1];
} ipAndNetmaskStruct;
typedef struct{
char port[PORT_LEN+1];
} portStruct;
static ipAndNetmaskStruct source[1024];
static ipAndNetmaskStruct dest[1024];
static portStruct source_port[1024];
static portStruct dest_port[1024];
//just an example of wha
void doSomthingWithStruct(the array and a specific field in each stcut in it){
for(int i=0;i<5;i++){
THEARRAY[i].SPECIFICFIELD="Somthing";
// as in source[i].ip="somthing";
}
}