Link problem

This is a discussion on Link problem within the C Programming forums, part of the General Programming Boards category; Hi Nice to meet you, I have problem about link between main.c and sub.h. The error message is "segment error". ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    2

    Link problem

    Hi
    Nice to meet you, I have problem about link between main.c and sub.h.
    The error message is "segment error".
    So my program is written as follow below:
    In main.c
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <math.h>
    
    #include "sub.h"
    
    int main()
    {
           double K[50000][50000];
    
           sub (K);
    }


    In sub.h
    Code:
    void sub(double K[][50000])
    {
        K[0][0]=5;  
    }
    It can be run if i use K[15000][15000].
    Why i can not use the array size bigger than 15000?
    Please help me.
    Thank you in advance.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,302
    Why i can not use the array size bigger than 15000?
    Stack size is more limited than heap size, so you have to use a dynamically allocated array instead.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    2
    Thank you very much
    I will try to do it.

  4. #4
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,832
    At 15,000 x 15,000 doubles you're already up to 1.6 GB. You won't be able to get as high as 16,384x 16,384 because I believe there's a 2 GB limit on memory any application can occupy. Or maybe 4 now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Link List problem
    By Darkinyuasha1 in forum C Programming
    Replies: 2
    Last Post: 05-08-2009, 08:47 PM
  2. destructor with a link list
    By Bones in forum C++ Programming
    Replies: 1
    Last Post: 09-24-2003, 01:01 PM
  3. Undefined Structure in Link List
    By _Cl0wn_ in forum C Programming
    Replies: 1
    Last Post: 03-22-2003, 05:57 PM
  4. .lib vs .h vs .dll
    By Shadow12345 in forum C++ Programming
    Replies: 13
    Last Post: 01-01-2003, 05:29 AM
  5. Link list and node problem
    By tom_mk in forum C++ Programming
    Replies: 0
    Last Post: 02-21-2002, 05:18 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21