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
2008-10-07 23:47:39
It should always be INT_MAX-1, because even if you only have 100megs of RAM, virtual memory will store the rest.
Orion Edwards
2008-10-08 00:00:08
@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
2008-10-08 00:04:05
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
2008-10-08 00:04:57
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
2008-10-08 03:34:59