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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:08:54+00:00 2026-05-26T22:08:54+00:00

A small query really with reference to Structs. If I had a Struct Node

  • 0

A small query really with reference to Structs.

If I had a

Struct Node { 
  char *number; 
  struct Node *next; 
 }List;

and a tree Structure:

struct Node {
  char *name;
  char *number;
  struct Node *right;
  struct Node *left;
};

and I wanted to design it, such that each Node within my Tree, can each contain a LIST of Phone Numbers, is there a way in which I can do this, and if so, how exactly can I reference my struct List within my Tree?

EDIT:

Any ideas as to why this is seg faulting? Using the Structs recommended below.

TreeNode* AddNode(TreeNode *root, ListNode *list, char *name, char *phonenum) {
int comparison;
if ( root == NULL ) {
    root = (TreeNode *)malloc(sizeof(TreeNode));
    list = (ListNode *)malloc(sizeof(ListNode));
    root->name = strdup(name); root->list->number = strdup(phonenum);
    root->left = root->right = NULL;    
  • 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-26T22:08:54+00:00Added an answer on May 26, 2026 at 10:08 pm

    You’d simply do it like so:

    typedef struct Node {
      char* name;
      List* list;
      struct Node *right;
      struct Node *left;
    } Node;
    

    Then in order to get a local copy of the first element of the list in each node, you’d do something like the following:

    Node* treenode; //this is pointing to some node in the tree
    
    char* num_buffer = strdup(treenode->list->number);
    //use num_buffer and then call free() on it when you're finished
    

    If you wanted to get a number that was not the first number in the list, you would have to create a search function for your linked list.

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

Sidebar

Related Questions

I am running a really simple query on a really small table (<10 rows,
i have small query as follows: If i will make view state property of
Hi i have a small query which takes data from one mysql database and
I have this small SQL query. SELECT a.`id` , a.`title` , a.`date` , (
I have a small but significant query. I'll give a similiar use case but
I'm creating a small forum. Attempting to run SElECT... JOIN... query too pick up
I need some help adding conditions to a linq query. Take this small example
I'm using LinqToSql to query a small, simple SQL Server CE database. I've noticed
i'm currently building a small music quiz running node.js 0.4.12 and the express framework
I wanted to write a small script that searched for an exact file name,

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.