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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:48:42+00:00 2026-05-27T04:48:42+00:00

I was loading data from database and inserting it into a map. When I

  • 0

I was loading data from database and inserting it into a map. When I tried to print the map size and data, it still shows size 1 and only the last row prints. All previous data is overwritten and contains last value. Any pointer in this
issue. I have changed variable names because of a company issue.

I have done some check Point also. All key values are unique.

typdef long_char char[38];

for(int j = 0; j < 31; j++)
{
    sample_enum param_sub_type = result_set[j];
    long_char param_name;

    strncpy(param_name,result_set[j], sizeof(param_name));
    input_status_cd.insert(std::pair<long_char,sample_enum>(param_name, param_sub_type));      

    /*Insert Into Map */    <I suspect this may be issue but not sure>
}

/*Printing Size of map */
input_status_sd::size_type input_status_cd_size;
etlog_msg(intput_status_cd_size :] [%d]",intput_status_cd.size());
  • 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-27T04:48:43+00:00Added an answer on May 27, 2026 at 4:48 am

    That is because long_char is defined as char[38] so when you insert into the map it will use try to use operator< which will result in comparing the address of the first char of the array. Since you are creating this array in the loop, most probably the same stack frame gets allocated so the address of the first char remains same for every object. Hence all the previous data gets overwritten as the map thinks that you are inserting the same object again. The simplest way to solve this would be to use std::string as a typedef for long_char.

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

Sidebar

Related Questions

I'm loading data from a MySQL database into a C# .NET application. The data
I'm loading data from my database into a DataTable, and one of the columns
I have a background worker that performs loading of data from the database into
I'm having trouble loading data from sqlite database into a detailed view. The table
Currently I am loading data from a previous session into my application using the
I am loading data from the database using mysql drivers for node.js. https://github.com/felixge/node-mysql I
We're essentially bulk loading data from one database to another, using SSIS. My co-worker
I'm inserting data from a jsf page to database using managed beans. But the
Hi I am developing an android in which I am loading data from database
I am using multithreading while loading data from the database. I am doing 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.