Thread: Maximum size of an array in C

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    7

    Maximum size of an array in C

    How can somebody increase the maximum size of an array?
    Using TC, it appears the max is 64 KB.
    Thanks for your help in advance.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > How can somebody increase the maximum size of an array?
    Get a compiler which isn't stuck in the stone age.
    Why oh why do people still use this crap?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    184
    it depends upon the memory capacity of the system. if there is no enough memory in the syystem then it throughs u an error telling segmenetation fault in gcc compile. no idea about the tc compiler. if you want to increase the array size in the run time better go to dynamic memory allocation..

  4. #4
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    nah, salem's right. you shouldn't be using turboC anymore. gcc is freely available.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  5. #5
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    Turbo C creates 16-bit code. And what's 2^16? That's right, 64KB. As suggested by everyone else, get a new compiler.
    If you understand what you're doing, you're not learning anything.

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >Using TC, it appears the max is 64 KB.
    You might try using the huge keyword:
    Code:
    int huge array[size];
    But your best bet has already been suggested.
    Last edited by swoopy; 01-25-2005 at 10:43 AM.

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    7
    Thanks for all applicable responses and I'm sorry if my question wasn't smart enough.
    By the way ,according to your advices I have searched on Internet for gcc compiler for hours and houres but I have encountered a lot of information that made me really mixed up.
    According to some sites it seems I should first install some other requirements to work in DOS and I think understanding the concept of GNU is necessary for understanding gcc but what is it? And I finally didn’t understand the relation between gcc and linux.
    Thanks for your patience!
    Don’t forget I’m not software engineer so be patient while helping please.
    Mehdi

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    http://faq.cprogramming.com/cgi-bin/...&id=1031248558
    http://www.thefreecountry.com/compilers/cpp.shtml
    http://compilers.net/
    Most newbies get DEV-C++, which is the GNU compiler with a nice IDE (text editor, debugger) wrapped around it.

    Once you've installed that, create a sample command line program
    File->New->Project
    choose the command line project type, and try this program
    Code:
    #include <stdio.h>
    int big[100000];
    int main ( ) {
        printf( "Size of array is %lu\n", (unsigned long)sizeof big );
        getchar();
        return 0;
    }
    Then do Execute->Compile and Run and see what happens.

    Stop calling it DOS if your operating system is at least as good as windows 95.
    For windows 95, 98, ME, you get a protected mode DOS emulator.
    For NT, 2K, XP you get a console, who's similarity to DOS ends at the C:\> prompt.

    > I think understanding the concept of GNU is necessary for understanding gcc
    Not at all - you can use gcc quite happily without knowing anything about GNU

    > And I finally didn’t understand the relation between gcc and linux.
    Linux is an operating system, gcc is a compiler.
    Most linux distributions come with gcc already installed.
    gcc is used to compile the linux kernel from source code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > it depends upon the memory capacity of the system.
    Erm, no it doesn't.
    If you're running XP and using TC, then even if XP can see 1GB, TC is still stuck with 640K.

    Now think back to when machines routinely had 512K of memory - try a museum.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. How do you use variable to initialize array size?
    By yougene in forum C Programming
    Replies: 11
    Last Post: 09-04-2007, 02:50 PM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Type and nontype parameters w/overloading
    By Mr_LJ in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2004, 01:01 AM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM