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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:38:46+00:00 2026-06-16T21:38:46+00:00

****New to C!**** I am running Dev-C++ 4.9.9.2 on Windows 7 (64 bit build)

  • 0

****New to C!****

I am running Dev-C++ 4.9.9.2 on Windows 7 (64 bit build)
My computer has 39GB of Physical Memory.

I am trying to create a large two dimensional array. I have already created code that tells me how many dimensions it has, and how many items are in each dimension.

As an example, let’s say the array is two dimensional: One million items long, and 6 wide:

[1,2,3,4,5,6],
[1,2,3,4,5,6],
[1,2,3,4,5,6],
...and on to one million items.

I have tried:

float MyArray[1000000][6];

but this crashes Dev-C. It seems to fail when I try to initialize an array larger than:

float Myarray[86486][6];

I imagine I am experiencing a “stack overflow” which amuses me since that is the name of this site.

I have been digging around and it seems I need to use malloc to help C understand how much memory to reserve. I have seen good examples of how to use this to set up a 1 dimensional array, but I would very much appreciate example code of how to set this up with a 2 dimensional array.

I have seen the example here: Initializing a large two dimensional array in C

But I’m afraid I am too much of a beginner in c to understand the brief explanation.
As background: I am coming from python where you can make an array of (almost) any size or dimension by just declaring MyArray=[] and then filling it with whatever you want.

Thank you!

  • 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-16T21:38:47+00:00Added an answer on June 16, 2026 at 9:38 pm

    Yeah, you’re running up against the limit of the size of an individual stack frame.

    Here’s one approach:

    #include <stdlib.h>
    ...
    int main(void)
    {
      /**
       * declare myArray as a *pointer* to a 6-element array of float
       */
      float (*myArray)[6];
      /**
       * dynamically allocate space for 1 million objects of type
       * "6-element array of float"
       */
      myArray = malloc(sizeof *myArray * 1000000);
      ...
      myArray[i][j] = ...;
    }
    

    Why this works:

    The subscript operation a[i] is interpreted as *(a + i); that is, we compute the address of the i‘th element (not byte) after a (the base address of the array) and dereference it. Since myArray is a pointer to a 6-element array of float, myArray[i] gives us the address of the i‘th 6-element array of float after myArray.

    The advantage of this approach is that the memory is allocated in a contiguous chunk, and you can subscript myArray like any 2-d array.

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

Sidebar

Related Questions

I'm running Django 1.2 beta and trying out the new feature: message framework. http://docs.djangoproject.com/en/dev/ref/contrib/messages/
I am trying to get the new PDO driver running in Code Igniter 2.1.1
I'm setting up a new dev environment on a Windows box, and after successfully
I've exchanged my dev machine (WinXP/32bit) to a new one (Windows 7/64bit). Now I
I was trying out this ajax example on my local machine running windows 7
Noob warning. I'm really new to Windows dev tools. I've got the latest Win8
I'm new to Windows Phone Dev., I intend to do: Set the canvas background
I am running windows 7 and I am trying to get this IDE to
So I'm trying to get an Asp.Net application running on Windows 2008R2 / IIS
I am new to running servers, but will Wget requests be logged in 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.