How many characters i can store

This is a discussion on How many characters i can store within the C++ Programming forums, part of the General Programming Boards category; How many characters i can store in a character array while i am having a ram of 1 GB....

  1. #1
    Registered User
    Join Date
    Jun 2007
    Location
    Qatar
    Posts
    39

    How many characters i can store

    How many characters i can store in a character array while i am having a ram of 1 GB.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,420
    That depends on your OS and compiler.

    If you're using crusty old turbo C, then 64K is your limit no matter how much RAM you have.

    But a more modern combination which allows you to use virtual memory might allow you to store more than your physical memory.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Salem View Post
    That depends on your OS and compiler.

    If you're using crusty old turbo C, then 64K is your limit no matter how much RAM you have.

    But a more modern combination which allows you to use virtual memory might allow you to store more than your physical memory.
    On windows (32-bit), the maximum limit would be 2GB with default settings, 3GB if you apply the /3GB switch in your boot.ini - of course, that would make it REALLY slow. If you want reasonably fast access to the content of a char array, limit it to about 80% of RAM-amount (unless you have other large applications).

    Also, if you use local variables on the stack, you don't have that much space, the default stack is fairly large, but not that many megabytes!


    --
    Mats

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    One megabyte by default in Windows. Subtract from that all the space normally needed, and you end up with a max length of perhaps 800-900k, if the program does nothing else.

    Under no circumstances will you be able to use more than 3 gigs of continuous memory in 32-bit Windows, and that requires special tricks. By default, you have 2 gigs of freely available address space. Furthermore, memory fragmentation means that you will probably not be able to allocate all the memory there is into a continuous block.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,288
    Quote Originally Posted by rehan View Post
    How many characters i can store in a character array while i am having a ram of 1 GB.
    Lots! How many do you need?
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Counting the characters from each word from a text file
    By flipguy_ph in forum C Programming
    Replies: 6
    Last Post: 04-27-2009, 05:56 PM
  2. store data from ifstream and store in link list
    By peter_hii in forum C++ Programming
    Replies: 2
    Last Post: 10-26-2006, 08:50 AM
  3. Replies: 4
    Last Post: 10-14-2005, 12:53 PM
  4. printing non-ASCII characters (in unicode)
    By dbaryl in forum C Programming
    Replies: 1
    Last Post: 10-25-2002, 01:00 PM
  5. how to store a node on hard disk
    By ALLRIGHT in forum C Programming
    Replies: 3
    Last Post: 05-13-2002, 10:11 AM

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