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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:16:02+00:00 2026-05-13T14:16:02+00:00

I’ve been trying to figure out pointers in C most of today, even asked

  • 0

I’ve been trying to figure out pointers in C most of today, even asked a question earlier, but now I’m stuck on something else. I’ve got the following code:

typedef struct listnode *Node;
typedef struct listnode {
    void *data;
    Node next;
    Node previous;
} Listnode;

typedef struct listhead *LIST;
typedef struct listhead {
    int size; 
    Node first;
    Node last; 
    Node current; 
} Listhead;

#define MAXLISTS 50

static Listhead headpool[MAXLISTS];
static Listhead *headpoolp = headpool;

#define MAXNODES 1000 

static Listnode nodepool[MAXNODES];
static Listnode *nodepoolp = nodepool;

LIST *ListCreate()
{
    if(headpool + MAXLISTS - headpoolp >= 1)
    {
        headpoolp->size = 0;
        headpoolp->first = NULL;
        headpoolp->last = NULL;
        headpoolp->current = NULL;
        headpoolp++;
        return &headpoolp-1; /* reference to old pointer */

    }else
        return NULL;
}

int ListCount(LIST list)
{
    return list->size;

}

Now in a new file I have:

#include <stdio.h>
#include "the above file"

main()
{
    /* Make a new LIST */
    LIST *newlist; 
    newlist = ListCreate();
    int i = ListCount(newlist);
    printf("%d\n", i);
}

When I compile, I get the following warning (the printf statement prints what it should):

file.c:9: warning: passing argument 1 of ‘ListCount’ from incompatible pointer type

Should I be worried about this warning? The code seems to do what I want it to, but I’m obviously very confused about pointers in C. After browsing questions on this site, I found that if I make the argument to ListCount (void *) newlist, I don’t get the warning, and I don’t understand why, nor what (void *) really does…

Any help would be appreciated, thanks.

  • 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-05-13T14:16:03+00:00Added an answer on May 13, 2026 at 2:16 pm

    You’re getting confused because of multiple typedefs. LIST is a type representing a pointer to struct listhead. So, you want your ListCreate function to return a LIST, not a LIST *:

    LIST ListCreate(void)
    

    The above says: ListCreate() function will return a pointer to a new list’s head if it can.

    Then you need to change the return statement in the function definition from return &headpoolp-1; to return headpoolp-1;. This is because you want to return the last available head pointer, and you have just incremented headpoolp. So now you want to subtract 1 from it and return that.

    Finally, your main() needs to be update to reflect the above changes:

    int main(void)
    {
        /* Make a new LIST */
        LIST newlist;  /* a pointer */
        newlist = ListCreate();
        int i = ListCount(newlist);
        printf("%d\n", i);
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a jquery bug and I've been looking for hours now, I can't
This could be a duplicate question, but I have no idea what search terms
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into

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.