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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:29:38+00:00 2026-05-31T13:29:38+00:00

I am learning C and attempting a crude implementation of a linked list in

  • 0

I am learning C and attempting a crude implementation of a linked list in C. Long story short I have a struct containing only a void pointer(element) and another pointer to the next node.(code to follow) My question is, when passing the head node and some other node into a new function, is there any way to ensure the two elements are of the same type? The two nodes should be able to hold any kind of data. Ive tried comparing with sizeof(), but am unable to deference a void pointer. Thanks in advance!

struct Node{
    void* element;
    struct Node* next;
}

This is the code for the nodes, I just need a way to compare them with assert to ensure a linked list with all of the same element types! 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-31T13:29:39+00:00Added an answer on May 31, 2026 at 1:29 pm

    No — you generally want to avoid a design like this, but if you really can’t avoid it, you typically need to put a enum in the node to tell you the type of data it contains.

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

Sidebar

Related Questions

I'm new to OCaml and attempting to implement List.append as a learning exercise. This
I'm attempting to craft my own basic singly linked list in C++ as a
I have just started learning OpenGL and I am attempting to make a game
Learning xml, Can anyone help me? I have following XML code: **<book lang=en>name of
I'm learning C and also at the same time attempting to implement a Python
I'm learning Perl and noticed a rather peculiar quirk -- attempting to match one
Climbing the learning mountain of TVirtualTreeView, I'm attempting to create a custom descendant that
I am attempting to do my own implementation of common data structures in C
As a learning project I'm attempting to re-create the procedurally generated hills from Tiny
I am just learning the basics of XHTML and am attempting to use the

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.