Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8129387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:17:33+00:00 2026-06-06T08:17:33+00:00

This code is giving me this error, which I don’t understand. I can’t even

  • 0

This code is giving me this error, which I don’t understand. I can’t even run the program. Can you help me to fix this error, please? If you don’t understand anything in the code, say it.

error C2040: 'CancelarPedido' : 'ppedido (ppedido)' differs in levels of indirection from ‘int ()’

printf("\nIntroduza opcao:");
    scanf("%d",&opc);

    switch(opc){
        case 1: lista = NovoPedido(lista);break;
        case 2: lista = CancelarPedido(lista);break;
        case 3: printf("Falta implementar a funcao.");break;
        case 4: printf("Falta implementar a funcao.");break;
    }
    }while(opc!=5);

    return lista;
}


ppedido CancelarPedido(ppedido lista)
{
    ppedido actual, anterior = NULL;

    char id[5];

    actual = lista;

    if(lista == NULL)
        printf("\nNao ha pedidos na fila de espera...");
    else
    {
        printf("\nIntroduza o ID do pedido que pretende cancelar: ");
        scanf("%s", id);

        while(actual != NULL && ((strcmp(actual->id, id)) != 0)){
            anterior = actual;
            actual = actual->prox;
        }
        if(actual == NULL){
            printf("\nERRO - Nao existe nenhum pedido com o ID introduzido.");
            return lista;
        }
        if(anterior == NULL){
            lista = actual->prox;
            printf("\nPedido cancelado com sucesso...");
        }
        else{
            anterior->prox = actual->prox;
            printf("\nPedido cancelado com sucesso...");
        }
        free(actual);
        return lista;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:17:35+00:00Added an answer on June 6, 2026 at 8:17 am

    You are calling CancelarPedido before you declared it. You need to reorder the code or add a forward declaration for CancelarPedido.

    Without a declaration of CancelarPedido in scope, it defaults to int CancelarPedido(). You get the error message because lista is declared to be a pointer but CancelarPedido is declared to return an int.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone tell me what's wrong with this code? It's giving me an error
I cannot understand why the code below is giving me this error in firebug
This my code, and it is giving me an unexpected $end error and I
This is my code in which every line is giving me an invalid context
Am trying to run a selenium suite using this code which runs perfectly on
I've simplified my JavaScript code to the example below; this code is giving me
For some reason this line of code is giving me quite a problem. struct
I have this piece of code that is giving me trouble. I know all
I copied the code from this link by giving company name and clicking the
This code below allows me to find the word error in all my files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.