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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:55:49+00:00 2026-05-31T06:55:49+00:00

I successfully wrote a C++ code for radix sort by creating 10 buckets. For

  • 0

I successfully wrote a C++ code for radix sort by creating 10 buckets. For the 10 buckets, I created them in this way:

struct node{
    struct node* next;
    long value;
};

struct node*bucket[10];

for (int i=0; i<10; ++i) {  
    bucket[i] = (struct node *) malloc (1000000*sizeof(struct node));
}

and it is perfect done.

But then now I need to raise the amount of my buckets to 100000. I tried to modified those buckets’ size like:

struct node*bucket[100000];

for (int i=0; i<100000; ++i) {  
    bucket[i] = (struct node *) malloc (1000000*sizeof(struct node));
}

But this time I think I can’t even create those buckets. I am using Visual Studio to code, and this is in C++. The compiler gave me these warnings:

: warning C4305: ‘argument’ : truncation from ‘__int64’ to ‘size_t’

: warning C4309: ‘argument’ : truncation of constant value

I searched it up in the internet, somebody says the number is too big. This is the first time I handle such a large number in the linked list. Do I need to modify anything to make this code work again?

Thank you. Any ideas and help I will be appreciated!

  • 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-31T06:55:51+00:00Added an answer on May 31, 2026 at 6:55 am

    I turned your code into a little sample program:

    #include <stdlib.h>
    
    struct node {
        int i;
    };
    
    int main()
    {
        struct node*bucket[100000];
    
        for (int i=0; i<100000; ++i) { 
            bucket[i] = (struct node *) malloc (1000000*sizeof(struct node));
        }
    }
    

    This compiles nicely with Visual Studio 2010.

    What comes to my mind is that you’re allocating an array of 100000 pointers (probably 4 bytes each). It reminds me of old compilers which wouldn’t let you use more than 64kB of stack space per variable (or function? I cannot remember. It was with Turbo Pascal or Turbo C…).

    Since this is C++, I suggest to just not use a raw C array in the first place. Instead, you can replace the above code with:

    #include <vector>
    
    struct node {
        int i;
    };
    
    int main()
    {
        std::vector<node> bucket( 100000 );
    }
    

    The std::vector object can be used in all cases where you’d use a C array.

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

Sidebar

Related Questions

I successfully used this code within a powerpoint odule, but when I move it
I successfully created database on my local server using Code First, migrated it to
I accidently wrote some code today that was like this: Private Sub Foo() Dim
I wrote an ASPX file in VB.NET. Originally this file ran successfully but after
this is the code i wrote to send the url request using a thread:
I wrote the code below that successfully gets a random line from a file;
I wrote this jQuery code: <script type=text/javascript> $.ajax({ url: http://www.mysite.com/login.aspx, context: document.body, success: function(html)
I wrote a chat application for Android using SocketChannel. It connects successfully with the
I successfully installed the latest QuantumGrid from DevExpress, but I've never worked with this
I successfully inserted some data into my sqlite database(I confirmed this by printing 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.