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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:23:30+00:00 2026-05-30T08:23:30+00:00

When I try to resize the list the program crashes… Look at that code,

  • 0

When I try to resize the list the program crashes… Look at that code, try to enter 1,000,000,000 (10^9)… On my windows 7 x64 doesnt work.

#include <cstdlib>
#include <iostream>
#include <list>

using namespace std;

int main(int argc, char *argv[])
{
    list<long long> l;

    long long n;
    cin>>n;

    cout<<l.max_size()<<endl;

    //uncomment 1 or 2

    //l.resize(n,l.size()+1); //1st try

    /*for (long long i=0; i<n; i++) //2nd try
        l.push_back(n);*/


    //system("PAUSE"); // uncomment if needed
    return 0;
}

The max size is over 4*10^9, but still doesnt work… Im using the newest MinGW (G++)

  • 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-30T08:23:32+00:00Added an answer on May 30, 2026 at 8:23 am

    Since “available memory” is a slightly fickle concept, l.max_size() returns a hard maximum. Your “crash” is very likely an uncaught std::bad_alloc, which you’d expect when running out of memory.

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

Sidebar

Related Questions

Try the following code public enum Color { Blue=1, Red=2, Green=3 } public List<Color>
try: spam.foo except AttributeError: do_somthing() (Is it wise to check an attribute like that
If i change the colour of the image and then try to resize, it
Every time I try to use my add function and return a list from
When I try to resize my glut window, the screen goes blank. This is
When I try to move my window(with a mouse) above my screen so that
I'm trying to resize an embedded object. The issue is that when the mouse
I can't get boost::multi_array resizing to work. When I try it, it gives errors
I have a problem when I try to resize a JLabel. In my application
Why doesn't this UIView layout code work as I want? Background: I have a

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.