how to do a subroutine on e1_insert,

Asked

Viewed 39 times

0

Guys, I CAN NOT create a subroutine for the 'e1_insert' function (SECOND SNIPPET). This function will be called every time you want to insert a drink. In this piece of code that I put here, it is only being called to the function choose_estera(SECOND SNIPPET OF CODE) but I do not know how to really call it

The goal of the project is an algorithm that receives products by data types, and stores them, in a STRUCT. The point is that these products can go to two types of mats. In other words, these products will be re-divided according to the treadmill, so I created a strct for each treadmill. In addition this data has to be entered by the user to then be manipulated ... NOTE: IF YOU NEED MORE INFORMATION

    void escolhe_estera(int e){
            printf("DIGITE '1' para a primeira esteira OU '2' para a 
    segunda esteira");
            scanf("%d", &e);
    if(e==1){
             // chamo as verificacoes
             int b;
       e1_insere(b)
            }
            else(e==2){
                    e1_insere(int b);
            }
       }
    

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

       void e1_insere(e1 *f, int b)
       {
          if(e1_lotada(f) == 1)
       {
             printf("Erro\n");
       }
       else
       {
       f -> topo++;
      
       f -> bebida[f-> topo] = b; 
                   e1_inicia (f);
                    printf("\nDigite o nome \n");
                    scanf("%s", &bebida[f->topo].nome);
                    printf("\nDigite o preco \n");
                    scanf("%f",&bebida[f->topo].preco);
                    printf("Digite o volume");
                    scanf("%f",&bebida[f->topo].volume);
       }

1 answer

0


C functions follow declaration precedence, that is, you cannot use a function that has not yet been declared to that point in the code.

Reorder your functions to follow the order of precedence and dependencies will be resolved. Avoid circular dependencies (a depends on b that depends on c that depends on a), or use header files( .h) that contain only the statements (the implementations are in .c), and use a #include no . c

To avoid duplicate inclusions use a structure like . h:

#ifndef MEU_ARQUIVO_H
#define MEU_ARQUIVO_H

int funca();
int funcb(int a, fload b);

#endif

Browser other questions tagged

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