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 8069687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:08:03+00:00 2026-06-05T13:08:03+00:00

recently, while reading former’s code in my current project, I encounter the problems below:

  • 0

recently, while reading former’s code in my current project, I encounter the problems below:

while implementing the Queue, my former wrote codes like this:

while(uq->pHead)
{
    char *tmp = uq->pHead;
    uq->pHead = *(char **)tmp;
    //...
}

the uq->pHead has definition like:

typedef struct {
        char* pHead;
        //...
} Queue;

Well, I’m quite confused about the usage that “uq->pHead = *(char**)tmp” , could anyone explain it to me in detail?

if we assume that *(uq->pHead) = 32(i.e. ‘ ‘) , *(char**)tmp would translate this into pointer-form, but…how could it make sense?

Thanks a lot.

  • 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-05T13:08:06+00:00Added an answer on June 5, 2026 at 1:08 pm

    Let’s suppose that we’re implementing your Queue as a linked list. We might have:

    struct data_type;
    
    struct node
    {
        node *next;
        data_type item;
    };
    
    struct linked_list
    {
        node *pHead;
        // ...
    };
    

    To empty the linked list, we might write:

    linked_list *uq=...;
    while (uq->pHead)
    {
        // unlink the first node from the list
        node *tmp = uq->pHead;
        uq->pHead = tmp->next; 
    
        // do something with that node
        // ...
    
        // deallocate the node
        free(tmp);
    }
    

    Now suppose we don’t really care about maintainable code, or are otherwise being lazy. We might instead just figure any pointer would do, and keep the structure for ‘node’ in our head, and write:

    linked_list *uq=...;
    while (uq->pHead)
    {
        // unlink the first node
        char *tmp = uq -> pHead;     // tmp points to the first 'node'
        uq -> pHead = *(char**)tmp;  // The first thing in a 'node' is a pointer to
                                     // the next node.
    
        // do something with 'tmp', the now unlinked node
        data_type *item=(data_type*) ( ((char**)tmp) + 1 ); // after the 'next' pointer
                                                            // is the real data.
        // ...
    
        // free up the node
        free(tmp);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently, while reading a Socket Programming HOWTO the following section jumped out at me:
Recently I have modified my code to While taking input form STDIN, I moved
I've been searching and reading up on SignalR recently and, while I see a
Recently I was reading about partitioning code with .NET assemblies and stumbled upon a
Recently I started reading (just a bit) the current draft for the future C++11
Possible Duplicate: Weird Java Boxing Recently while I was reading about wrapper classes I
I've recently started reading up on Rails and while getting my development environment ready
I've been getting an error recently while debugging an ASP.NET application in Visual Studio
Recently I opened a .dll file produced by Visual Studio 9 while compiling a
Recently, I use Vim as my editor while programming Ruby, but I don't know

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.