Thread: Arrays failing to work

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    10

    Arrays failing to work

    Hi all,

    I'm having a huge issue over a simple problem. I'm trying to initialize two arrays which are fairly large.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
    
     unsigned short Projections[336][265][283];
     unsigned short Michelogram[18][18][336][283];
    
     printf("\n-=<This program ran successfully>=-\n\n");
    
     return 0;
    
    }
    This compiles fine, but when I run it, I get:
    Segmentation fault (core dumped)

    I've been compiling this snippet on gcc 3.3.2 in Red Hat Linux Fedora core 1. I haven't compiled this on Windows Bloodshed Dev-C++ yet.

    What confuses me is that this code below works:
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
    
     /*unsigned short Projections[336][265][283]; */
     unsigned short Michelogram[18][18][336][40];
    
     printf("\n-=<This program ran successfully>=-\n\n");
    
     return 0;
    }
    By getting rid of one array, and toning down the other, it works.

    It's almost as if these arrays have a maximum size, or something to that effect. At first, I thought this was a memory issue. The computer I'm running it on is a P3 300MHz w/ 128MB SDRAM. I compiled it on a Dual Xeon 2.4GHz with more RAM, but I still got the same error.

    Anyone else have this problem?

    Any suggestions would be extremely helpful.

    Cheers,
    Bri Rock
    Last edited by Bri Rock; 06-14-2004 at 12:45 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function to read in two arrays
    By ssmokincamaro in forum C Programming
    Replies: 7
    Last Post: 11-12-2008, 07:59 AM
  2. Manipulating Character arrays in functions.
    By kbro3 in forum C++ Programming
    Replies: 11
    Last Post: 08-16-2008, 02:24 AM
  3. Global arrays shared between multiple source files
    By mike_g in forum C Programming
    Replies: 4
    Last Post: 08-14-2008, 06:29 PM
  4. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  5. The Bludstayne Open Works License
    By frenchfry164 in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 11-26-2003, 11:05 AM