> Hvordan kan man initialisere et array af struct til nogle bestemte
værdier?
>
> Jeg har en struct :
> typedef struct {
> UINT16 opAddress;
> BYTE hwAddress[6];
> BYTE connHandle[2];
> BYTE device;//this is the device driver number
> } NeighbourEntry;
> nu vil jeg gerne at alle struct elementer i
> NeighbourEntry neighbourTable[MAXNEIGHBOURSIZE];
> bliver initialiseret til:
> { 0, {0},{0xFF,0xFF},0 }
> altså alt nul undtagen connHandle, men det virker ikke at skrive
>
> NeighbourEntry neighbourTable[MAXNEIGHBOURSIZE]={ 0, {0},{0xFF,0xFF},0 };
Hej Kim tjek længere nede ved stjernerne. Sådan løste jeg dette problem.
Sikkert ikke den mest elegante, men det virker!!
N
/* FILE SPSKGR.H */
/* Sporskift erkl'ringer */
#define SPSKGR_H_VER "2.11 Dato 07/05-2001"
#ifndef __SPSKGR_H
#define __SPSKGR_H
#endif
#ifndef __GRPL_H
#include "grpl.h"
#endif
#ifndef __SPSK_H
#include "spsk.h"
#endif
#ifndef __IOKORT_H
#include "iokort.h"
#endif
const UBYTE SpskGrAnt=8;
const UBYTE SpskGrMaxKoer=1;
struct In1 const SpskGrFknp={1};
struct In2 const SpskGrInk00={33, 32};
struct Out1 const SpskGrMot00={8};
struct In1 const SpskGrKnp00={24};
struct spskvar SpskGrVar00={0,0,FALSK,FALSK,FALSK,&GrBs.Bl[0],NULL};
struct In2 const SpskGrInk01={35,34};
struct Out1 const SpskGrMot01={9};
struct In1 const SpskGrKnp01={25};
struct spskvar SpskGrVar01={0,0,FALSK,FALSK,FALSK,&GrBs.Bl[1],NULL};
struct In2 const SpskGrInk02={37,36};
struct Out1 const SpskGrMot02={10};
struct In1 const SpskGrKnp02={26};
struct spskvar SpskGrVar02={0,0,FALSK,FALSK,FALSK,&GrBs.Bl[2],NULL};
struct In2 const SpskGrInk03={39,38};
struct Out1 const SpskGrMot03={11};
struct In1 const SpskGrKnp03={27};
struct spskvar SpskGrVar03={0,0,FALSK,FALSK,FALSK,&GrBs.Bl[3],NULL};
struct In2 const SpskGrInk04={41,40};
struct Out1 const SpskGrMot04={12};
struct In1 const SpskGrKnp04={28};
struct spskvar SpskGrVar04={0,0,FALSK,FALSK,FALSK,&GrBs.Bl[4],NULL};
struct In2 const SpskGrInk05={43,42};
struct Out1 const SpskGrMot05={13};
struct In1 const SpskGrKnp05={29};
struct spskvar SpskGrVar05={0,0,FALSK,FALSK,FALSK,&GrBs.Bl[5],NULL};
struct In2 const SpskGrInk06={45,44};
struct Out1 const SpskGrMot06={14};
struct In1 const SpskGrKnp06={30};
struct spskvar SpskGrVar06={0,0,FALSK,FALSK,FALSK,&GrBs.Bl[6],NULL};
struct In2 const SpskGrInk07={47,46};
struct Out1 const SpskGrMot07={15};
struct In1 const SpskGrKnp07={31};
struct spskvar SpskGrVar07={0,0,FALSK,FALSK,FALSK,&GrBs.Bl[7],NULL};
**** Her er min version af samme problem ****
struct spsk SpskGr[SpskGrAnt]=
{
&SpskGrInk00, &SpskGrMot00, &SpskGrKnp00, NULL, &SpskGrVar00, NULL,
&SpskGrInk01, &SpskGrMot01, &SpskGrKnp01, NULL, &SpskGrVar01, NULL,
&SpskGrInk02, &SpskGrMot02, &SpskGrKnp02, NULL, &SpskGrVar02, NULL,
&SpskGrInk03, &SpskGrMot03, &SpskGrKnp03, NULL, &SpskGrVar03, NULL,
&SpskGrInk04, &SpskGrMot04, &SpskGrKnp04, NULL, &SpskGrVar04, NULL,
&SpskGrInk05, &SpskGrMot05, &SpskGrKnp05, NULL, &SpskGrVar05, NULL,
&SpskGrInk06, &SpskGrMot06, &SpskGrKnp06, NULL, &SpskGrVar06, NULL,
&SpskGrInk07, &SpskGrMot07, &SpskGrKnp07, NULL, &SpskGrVar07, NULL
};
struct spskconst const SpskGrConst=
{
SpskGrAnt,
SpskGrMaxKoer,
GrScr,
&SpskGrFknp,
NULL
};
struct spskdef GrSpsk=
{
// Omst, Magz, Fejl, OvStrp, CkOvStrp, OvStrpStart, CkOvStrpStart
0, 0, FALSK, FALSK, FALSK, 0, 0,
&SpskGrConst,
SpskGr,
NULL,
NULL,
NULL,
NULL
};
|