Doubt struct error

0

I am trying to make this code work but I do not understand why I get the error:

pruebas.c:13:2: error: ‘array1’ undeclared (first use in this function)
  array1.array[0] = 1;
  ^~~~~~
pruebas.c:13:2: note: each undeclared identifier is reported only once for each function it appears in
pruebas.c:14:14: error: ‘array’ undeclared (first use in this function); did you mean ‘array1’?
  printf("%d",array[0]);
              ^~~~~
              array1

Code:

#include <stdio.h>
#include <stdlib.h>
#define MAX_ELEMENTS 5

void init(void);

struct structArray
{
    int array[MAX_ELEMENTS];
}; 

void init(void){
    array1.array[0] = 1;
    printf("%d",array1.array[0]);
}

int main(int argc,char** argv) {

 struct structArray array1;
 init();



 return 0;
}

Could it be that the order of declaration is not correct?

    
asked by Chariot 02.01.2019 в 17:05
source

0 answers