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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:28:05+00:00 2026-05-26T20:28:05+00:00

Just as a disclaimer, I am not looking for any hard code solutions, but

  • 0

Just as a disclaimer, I am not looking for any hard code solutions, but merely a nudge in the right direction.

Essentially, I need to create a tree, that contains two arrays of data in each Node and two separate arrays of chars.

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

That’s my struct at the moment, and the input is in the form:

name number
name number
name number
.

The . being the termination, now, I have a theory for how to parse that, i.e. getchar until . and scanf the name and number into an array. But from this point, I’m unsure how exactly I need to pass those arrays to a function to add the stuff to the tree, where I define the size of the array, etc. Can someone give some tips for this problem?

  • 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-26T20:28:06+00:00Added an answer on May 26, 2026 at 8:28 pm

    First of all, you need to use dynamic memory. The size of your arrays will be defined at runtime, after you have read them, from a file I guess.

    If the char* you read are null-terminated (i.e. the last character is ‘\0’), you can use the strlen function to get their size, and pass that value to malloc in order to allocate the memory before you use strcpy to copy the string into that memory. Don’t forget to call free to return everything you malloc‘ed

    So just pass two char* to the function which will insert them in your data structure (is it a binary tree or a try? You used one term in the title and another in your question)

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

Sidebar

Related Questions

(DISCLAIMER: I'm not a programmer, I spend my time on serverfault, I'm just a
First the disclaimer: I never learnt any programming in school, and just have to
Disclaimer: I'm not very good at Java and just comparing read/writer locks between C#
Disclaimer, I not do anything in particular with regards this question, just curious. Is
A little disclaimer before I get ridiculed for not putting up code examples: I
Disclaimer: I am anything but a Javascript expert, so I'm not even sure if
Disclaimer: I'm not actually trying to make one I'm just curious as to how
Just for the disclaimer, I'm not trying to win the prize in Android Developer
Disclaimer: I have already seen the following questions and their solutions did not apply
DISCLAIMER: This is not a real-world example. It is just a theoretical question of

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.