tags:

views:

1518

answers:

3

What is the maximum length in characters a CString object can hold?

+4  A: 

Up to your available memory or INT_MAX-1 (whichever is less).

Franci Penov
It should always be INT_MAX-1, because even if you only have 100megs of RAM, virtual memory will store the rest.
Orion Edwards
@Orion: only to a point. On 32-bit Windows, user-mode programs will have somewhat less than 2GB of address space available (since the program itself will take up some space).
Shog9
The length is not limited only to the available memory, but to the size of the largest available continuous memory block. Which could be less than INT_MAX-1, depending on what else you have loaded in the memory and how fragmented your heap is.
Franci Penov
He asked for the length in characters, not bytes, so the size of the character matters: `sizeof(TCHAR)` could be 1 or 2 depending on whether `UNICODE` is `#define`ed somewhere.
Brian Ensink
+2  A: 

INT_MAX - 1

Alf Zimmerman
A: 

2,147,483,647 characters

Jim In Texas