array type has incomplete element type

Asked

Viewed 65 times

0

I am not able to compile my program, the compiler keeps accusing "array type has incomplete element type" in the function that prints points.

The function that prints dot:

 float imprimePonto(struct armazenar p[], int n)
{
    int i;
    for(i=0;i<n;i++)
    {
        printf("(%9.2f, %9.2f)\n",p[i].x,p[i].y);
    }
    return 0;
}

the struct:

struct armazenar
{
    float x;
    float y;
};

main:

#define MAX 10
    int main()
    {
        struct armazenar p[MAX];
        int n=0;

        n=func_lerN();//recebendo o numero de vetores que o usuario quer digitar.

        func_lerVetor(n);
        imprimePonto(p[MAX],n);


        return 0;
    }
  • as this is being declared the array in the main code?

  • Visual Studio Express works perfectly.

  • Put the struct code in the same file, above the declaration of your function.

  • failed to put the struct code in the same file.

  • Compiling as? (Which Compiler, which environment, which build command, etc)? What structure (it’s all in the same file .c with no one header?)?

  • has a header and I use code Blocks

Show 2 more comments

1 answer

0

On the line imprimePonto(p[MAX],n); the vector itself should be passed as it is in the function signature float imprimePonto(struct armazenar p[], int n), or should replace imprimePonto(p[MAX],n); for imprimePonto(p,n);.

The p[MAX] is a vector position, in this case invalid, if you want to pass the vector itself you have to indicate the vector p and not a position of the same.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.