Row function in C

Asked

Viewed 453 times

1

Guys, I have to do a de-rank function. Receive from the user: -1 to un-row an element or 2 to queue an element That is to say the user to queue has to type option 2 and then enter the values and go adding so. If it wants to remove a value from the queue the user will type -1 and will remove, removing until empty.

I did the queuing, I want to know how does the rowing.

#define TAM_FILA 10

typedef struct
{
    int inicio, fim;
    int fila[TAM_FILA];
} tipo_fila;

int desenfileirar(tipo_fila *fila)
{
    //printf("\n\n Desenfileirar ...\n");

    if(fila->inicio==fila->fim)
    {
        printf ("Fila vazia!");
    }
    else
    {
        /*int i;
        for(i=0; i < TAM_FILA; i++)
        {
            fila->fila[i]=fila->fila[i+1];
        }
        fila->fila[fila->fim]=0
        fila->fim--;*/
    }
    return 0;
}
  • The commented code is partially correct ... the only problem is that it can access an element outside the array ... try to fix this

  • then I went back to use it, and error when I call him.

No answers

Browser other questions tagged

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