CString max character length
-
hello, I remember reading once that a CString object has a maximum amount of characters it can hold, I just can't seem to find how much that is. Does anybody know how much that count is? If you have a URL with that info that would also be neat. Greetings, Davy
-
hello, I remember reading once that a CString object has a maximum amount of characters it can hold, I just can't seem to find how much that is. Does anybody know how much that count is? If you have a URL with that info that would also be neat. Greetings, Davy
sure, check it's index type... you'll figure out how far it can go (so, how many TCHARs a CString can hold)
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
hello, I remember reading once that a CString object has a maximum amount of characters it can hold, I just can't seem to find how much that is. Does anybody know how much that count is? If you have a URL with that info that would also be neat. Greetings, Davy
From memory 32767. Two things to note- The best way to confirm this is to look at the CString source. The other thing that doing this will confirm for you is that if you're going anywhere near needing to know what the limit is you shouldn't be using CStrings. A preallocated 32K or 64K character buffer will likely be serveral times faster, depending on what you're doing with it of course, and the Win32 API and MSVCRT have a vast array of string functions that operate directly on character arrays. Good luck.
Nothing is exactly what it seems but everything with seems can be unpicked.
-
hello, I remember reading once that a CString object has a maximum amount of characters it can hold, I just can't seem to find how much that is. Does anybody know how much that count is? If you have a URL with that info that would also be neat. Greetings, Davy
-
From memory 32767. Two things to note- The best way to confirm this is to look at the CString source. The other thing that doing this will confirm for you is that if you're going anywhere near needing to know what the limit is you shouldn't be using CStrings. A preallocated 32K or 64K character buffer will likely be serveral times faster, depending on what you're doing with it of course, and the Win32 API and MSVCRT have a vast array of string functions that operate directly on character arrays. Good luck.
Nothing is exactly what it seems but everything with seems can be unpicked.
are you sticking to Windows 3.1 with MFC 3 ?? :~ and suggest to use std::string rather than allocating a 32K buffer ! WTF !!!
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
From memory 32767. Two things to note- The best way to confirm this is to look at the CString source. The other thing that doing this will confirm for you is that if you're going anywhere near needing to know what the limit is you shouldn't be using CStrings. A preallocated 32K or 64K character buffer will likely be serveral times faster, depending on what you're doing with it of course, and the Win32 API and MSVCRT have a vast array of string functions that operate directly on character arrays. Good luck.
Nothing is exactly what it seems but everything with seems can be unpicked.
Thanks for the reply. The required space is luckily not really near the 32K. It's just that I have a bug with some rather big strings 9+K not passing over a socket connection and I just wanted to make sure that the CString was not the cause of it. Greetings, Davy
-
are you sticking to Windows 3.1 with MFC 3 ?? :~ and suggest to use std::string rather than allocating a 32K buffer ! WTF !!!
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
std::string is fine if you don't care how the code you're using works. To most developers it's still unreadable gibberish with inadequate usage documentation of precisely the 'how much can it hold' type that the OP is interested in. I code on everything from Windows 3.11 to Vista and on CE in what is still, essentially, MFC 3, have written my own replacement CString class and have written a commercial inline parser generator which uses preallocated 64K text buffers, simple, reliable, consistent, fast and easy to understand. So yes if someone is struggling with determining a size limit from the CString code and dealing with 32K+ lumps of text data then I think simple buffers are good advice. KISS was the first and last thing my C++ lecturers ever taught me.:)
Nothing is exactly what it seems but everything with seems can be unpicked.
-
From memory 32767. Two things to note- The best way to confirm this is to look at the CString source. The other thing that doing this will confirm for you is that if you're going anywhere near needing to know what the limit is you shouldn't be using CStrings. A preallocated 32K or 64K character buffer will likely be serveral times faster, depending on what you're doing with it of course, and the Win32 API and MSVCRT have a vast array of string functions that operate directly on character arrays. Good luck.
Nothing is exactly what it seems but everything with seems can be unpicked.
Matthew Faithfull wrote:
From memory 32767.
Sounds like you need a memory update.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Matthew Faithfull wrote:
From memory 32767.
Sounds like you need a memory update.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
My 250TB is just fine. If only I could find the runtime to re-index it:)
Nothing is exactly what it seems but everything with seems can be unpicked.
-
Thanks for the reply. The required space is luckily not really near the 32K. It's just that I have a bug with some rather big strings 9+K not passing over a socket connection and I just wanted to make sure that the CString was not the cause of it. Greetings, Davy
GDavy wrote:
It's just that I have a bug with some rather big strings 9+K not passing over a socket connection
String length isn't the problem, but what's going on with your sockets? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
hello, I remember reading once that a CString object has a maximum amount of characters it can hold, I just can't seem to find how much that is. Does anybody know how much that count is? If you have a URL with that info that would also be neat. Greetings, Davy
Can you say why do you need to max length of CString,please?