How many characters i can store in a character array while i am having a ram of 1 GB.
How many characters i can store in a character array while i am having a ram of 1 GB.
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.
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
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
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"