Thread: Array Sizing

  1. #1
    Registered User
    Join Date
    Dec 2005

    Array Sizing

    Ok, here goes...

    I have read and searched several threas here that are concerned with the size of arrays and how they should not be too large. I have seen that an answer to this is vectors. I have absolutely no idead what vectors are. What I want to do is have three single dimension arrays that are size 1,000,000. Yes, I know this is probably a bad way to do it but it is also a very simple way to do what I want. I guess out of all of my ramblings the question is how do I get Microsoft Visual C++ 6.0 to accept this array size?

    Thank you,


  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    The usual problem is one of running out of stack space when you make such large arrays local parameters to a function.
    For example, this is generally a bad idea
    int main ( ) {
      int big[1000000];
    You can make them static, which preserves scope, but does not actually place them on the stack, like so.
    int main ( ) {
      static int big[1000000];
    If you don't know how many you need until the program is running, then you have to dynamically allocate them.
    int main ( ) {
      int howmany = 1000000; // or however you work it out.
      int *big = new int[howmany];
    No matter which way you go, you still have big[index] type access and any of them can be passed (as a pointer) to other functions without rewriting the function.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 10:33 AM
  3. Replies: 6
    Last Post: 11-09-2006, 03:28 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM