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
    23,806
    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.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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,833
    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, 07:47 PM
  2. destructor with a link list
    By Bones in forum C++ Programming
    Replies: 1
    Last Post: 09-24-2003, 12:01 PM
  3. Undefined Structure in Link List
    By _Cl0wn_ in forum C Programming
    Replies: 1
    Last Post: 03-22-2003, 04:57 PM
  4. .lib vs .h vs .dll
    By Shadow12345 in forum C++ Programming
    Replies: 13
    Last Post: 01-01-2003, 04:29 AM
  5. Link list and node problem
    By tom_mk in forum C++ Programming
    Replies: 0
    Last Post: 02-21-2002, 04:18 PM

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