"[Error] expected expression before 'creature'" in function

1

The board is a "creature" of my struct:

typedef struct{
    int status;
    char classe;
    int saude;
    int def;
    int atc;
    char elixir;
}criatura;

No .h:

void exibe(criatura tabuleiro[5][10]); // exibe o tabuleiro

The call in .c with the functions:

criatura tabuleiro[5][10]; // declarei aqui
// entraram alguns códigos aqui
exibe(criatura tabuleiro); // chamei a função aqui

The function:

void exibe(criatura tabuleiro[5][10]){
    int i,j;

    for(i=0;i<10;i++){
        if(i==0){
            printf("     1");
        }
        if(i==1){
            printf("   2");
        } ............................. (apenas um tabuleiro)

But for some reason I get the error:

In function 'tabuleiro':
[Error] expected expression before 'criatura'
C:\Users\...\dfv2\Makefile.win  recipe for target 'funcoes.o' failed

If someone knows what's going wrong, thank you! A hug!

    
asked by anonymous 11.11.2017 / 23:46

1 answer

1

The function call is wrong.

You did:

exibe(criatura tabuleiro);

Should have done:

exibe(tabuleiro);

The C already knows that it is a creature. In this case, you confused the compiler by giving it a type and a name. And this structure is not valid when calling a function. In this case, grammar C requests that a call be made up of:

  • Function name
  • Open parenthesis
  • Values merged by commas
  • Close parenthesis
  • It has some variations (C accepts function pointers), but in general this is it.

    It is also worth saying that for header it is necessary to know the type criatura before declaring the function.

        
    11.11.2017 / 23:59