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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:34:54+00:00 2026-06-14T14:34:54+00:00

This is a rough idea of what I am doing: Map map; create_map(map); //initialize

  • 0

This is a rough idea of what I am doing:

Map map;
create_map(map); //initialize map
Value x,y;
while(...){
  ...
  x = ...;
  y = ...;
  put(map, x, (void *) &y);
  ...
}

Map is of type {Value, (void *)}. The Map is custom written but I did not write it. I am trying to figure out where it is defined and will update if I find it. All the map does is store the association of a Value and a (void *) in a struct of some sort.

I think what is going on is that the value, y, inserted into the map is not getting the value I want. It is storing whatever value y is after the while loop executes. I want the address of each iteration to be different and pointing to a different version of y.

So with the code above, for any key X in the map, they all point to the same value. I want them to point to different values.

  • 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-14T14:34:55+00:00Added an answer on June 14, 2026 at 2:34 pm

    To do what you want, you will need to allocate different copies of “Value”, something like this:

    Map map;
    Value x;
    Value *y;
    create_map(map); //initialize map
    while(...){
      ...
      x = ...;
      y = malloc(sizeof(Value));
      *y = ...;
      put(map, x, (void *) y);
      ...
    }
    

    Just don’t forget to deallocate at the end.

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

Sidebar

Related Questions

this is a rough idea of what my program looks like MainTabHost Activity (startup)
this is just a rough idea, i am trying to create a magazine reading
this is the rough idea of what I am trying to do: I want
I am using this JQuery Ajax Voting system guide as a rough reference but
SOLVED! My Activity Stack looks like this, excuse the rough diagram! A-->B-->C '-->D If
I've been doing problems on recursion in my Data Structures & Algorithms class and
I'm a beginner in sql and I am doing this through a php document.
So, my rough idea of linear interpolation applied to fog stems from the Wikipedia
I am developing social networking app on android.Rough idea of my app is that
Only got rough idea of what I want, perhaps someone could pad it out

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.