S
Sheldon
Hi,
Can anyone help with this problem with setting up nested structures
and initializing them for use.
I have created several structs and placed them in a super struct that
I will then pass to some functions. I have defined them in the
following manner:
typedef struct trans Transient;
typedef struct sats Satellites;
typedef struct data Data;
typedef struct super Super;
struct data {
float table_10[ROW*COL];
float table_20[ROW*COL];
float table_30[ROW*COL];
float table_40[ROW*COL];
float table_50[ROW*COL];
float table_60[ROW*COL];
float procent_amsu;
};
struct trans {
char operationalfile[MAXSTR_LENGTH];
char tunedfile[MAXSTR_LENGTH];
char radarfile[MAXSTR_LENGTH];
float amsu_flag[ARRAYSIZE];
float radar[ARRAYSIZE];
float pcpn1[ARRAYSIZE];
float pcpn2[ARRAYSIZE];
float pcpn3[ARRAYSIZE];
};
struct sats {
Data *pN18;
Data *pN17;
Data *pN16;
Data *pN15;
Data *pM02;
};
struct super {
Transient *TR;
Satellites *Sp;
Satellites *Su;
Satellites *Au;
Satellites *Wi;
};
Super* InitStruct(void);
Now when I try to intialize the structure I get a bunch of errors. The
InitStruct functions looks like this:
int main() {
Super *sptr;
/* initializing the super structure */
sptr = InitStruct();
if (sptr == NULL) {
fprintf(stderr,"Failed to initialize nested structure!\n");
exit(EXIT_FAILURE);
} else {
printf("Structure now initialized!\n");
}
return 1;
}
Super *InitStruct(void) {
Super *sptr=NULL;
if(!(sptr=malloc(sizeof(Super)))) {
return NULL;
}
sptr->TR->operationalfile=NULL;
sptr->TR->tunedfile=NULL;
sptr->TR->radarfile=NULL;
sptr->TR->amsu_flag={0.0};
sptr->TR->radar={0.0};
sptr->TR->pcpn1={0.0};
sptr->TR->pcpn2={0.0};
sptr->TR->pcpn3={0.0};
sptr->Sp->N18->table_10={0.0};
sptr->Sp->N18->table_20={0.0};
sptr->Sp->N18->table_30={0.0};
sptr->Sp->N18->table_40={0.0};
sptr->Sp->N18->table_50={0.0};
sptr->Sp->N18->table_60={0.0};
sptr->Sp->N18->procent_amsu = 0.0;
sptr->Sp->N17->table_10={0.0};
sptr->Sp->N17->table_20={0.0};
sptr->Sp->N17->table_30={0.0};
sptr->Sp->N17->table_40={0.0};
sptr->Sp->N17->table_50={0.0};
sptr->Sp->N17->table_60={0.0};
sptr->Sp->N17->procent_amsu = 0.0;
.....
}
The errors begin with these:
error: incompatible types in assignment
error: incompatible types in assignment
error: incompatible types in assignment
error: parse error before '{' token
error: parse error before '{' token
and keeps on going.
Could some please render some help in doing this correctly?
Any help is truly appreciated.
/S
Can anyone help with this problem with setting up nested structures
and initializing them for use.
I have created several structs and placed them in a super struct that
I will then pass to some functions. I have defined them in the
following manner:
typedef struct trans Transient;
typedef struct sats Satellites;
typedef struct data Data;
typedef struct super Super;
struct data {
float table_10[ROW*COL];
float table_20[ROW*COL];
float table_30[ROW*COL];
float table_40[ROW*COL];
float table_50[ROW*COL];
float table_60[ROW*COL];
float procent_amsu;
};
struct trans {
char operationalfile[MAXSTR_LENGTH];
char tunedfile[MAXSTR_LENGTH];
char radarfile[MAXSTR_LENGTH];
float amsu_flag[ARRAYSIZE];
float radar[ARRAYSIZE];
float pcpn1[ARRAYSIZE];
float pcpn2[ARRAYSIZE];
float pcpn3[ARRAYSIZE];
};
struct sats {
Data *pN18;
Data *pN17;
Data *pN16;
Data *pN15;
Data *pM02;
};
struct super {
Transient *TR;
Satellites *Sp;
Satellites *Su;
Satellites *Au;
Satellites *Wi;
};
Super* InitStruct(void);
Now when I try to intialize the structure I get a bunch of errors. The
InitStruct functions looks like this:
int main() {
Super *sptr;
/* initializing the super structure */
sptr = InitStruct();
if (sptr == NULL) {
fprintf(stderr,"Failed to initialize nested structure!\n");
exit(EXIT_FAILURE);
} else {
printf("Structure now initialized!\n");
}
return 1;
}
Super *InitStruct(void) {
Super *sptr=NULL;
if(!(sptr=malloc(sizeof(Super)))) {
return NULL;
}
sptr->TR->operationalfile=NULL;
sptr->TR->tunedfile=NULL;
sptr->TR->radarfile=NULL;
sptr->TR->amsu_flag={0.0};
sptr->TR->radar={0.0};
sptr->TR->pcpn1={0.0};
sptr->TR->pcpn2={0.0};
sptr->TR->pcpn3={0.0};
sptr->Sp->N18->table_10={0.0};
sptr->Sp->N18->table_20={0.0};
sptr->Sp->N18->table_30={0.0};
sptr->Sp->N18->table_40={0.0};
sptr->Sp->N18->table_50={0.0};
sptr->Sp->N18->table_60={0.0};
sptr->Sp->N18->procent_amsu = 0.0;
sptr->Sp->N17->table_10={0.0};
sptr->Sp->N17->table_20={0.0};
sptr->Sp->N17->table_30={0.0};
sptr->Sp->N17->table_40={0.0};
sptr->Sp->N17->table_50={0.0};
sptr->Sp->N17->table_60={0.0};
sptr->Sp->N17->procent_amsu = 0.0;
.....
}
The errors begin with these:
error: incompatible types in assignment
error: incompatible types in assignment
error: incompatible types in assignment
error: parse error before '{' token
error: parse error before '{' token
and keeps on going.
Could some please render some help in doing this correctly?
Any help is truly appreciated.
/S