My goal with this piece of code is to create an array of 1000 positions, containing a struct which contains an int (to be used as a counter) and a nested struct initialized as an array of 100 positions. Am I designing this correctly?
As in, I'm trying to achieve a bidimensional table of 1000 columns by 100 rows, where these 100 rows each have the before mentioned int to be used as a counter/index variable, and each position in the 100 rows array to be comprised by the nested struct! This is what I got so far:
#define DATA_MAX 1000
#define MAX_CHAR_TIPO_MOV 60
#define MAX_CHAR_DESCRICAO 60
#define MAX_MOVIMENTOS 100
#define BUFFLEN 1024
char buffer[BUFFLEN];
typedef struct{
int montante;
int data;
int periodicidade;
char tipo[MAX_CHAR_TIPO_MOV];
char descricao[MAX_CHAR_DESCRICAO];
}sistema;
typedef struct{
int indice;
struct sistema tabela[MAX_MOVIMENTOS]; /* Compiler gives me an error here: array type has incomplete element type */
}movimentos;
movimentos c[DATA_MAX];
/* Function to initialize arrays/structs in order to eliminate junk */
void inicializarfc(movimentos c[])
{
int i, j;
//percorre o vector estrutura
for(i=0; i<DATA_MAX; i++)
for(j=0; j<MAX_MOVIMENTOS; j++)
{
c[i].[j].data = -1;
c[i].[j].montante = -1;
c[i].[j].periodicidade = -1;
memset((c[i].[j].tipo), ' ', sizeof(c[i].[j].tipo));
memset((c[i].[j].descricao), ' ', sizeof(c[i].[j].descricao));
}
}
If indeed it is possible to create what I'm asking, how should I go about to access the structure members? Compiling in Codeblocks 10.05 in W7 using GCC.