Is there a way to make char strings(arrays I guess) dynamic? I need to be able to resize and redefine the value. Unfortunately none of the string headers Ive found use chars
Printable View
Is there a way to make char strings(arrays I guess) dynamic? I need to be able to resize and redefine the value. Unfortunately none of the string headers Ive found use chars
download:
http://lvp.com/data/cpluspc/string.cpp
http://lvp.com/data/cpluspc/string.h
http://lvp.com/data/cpluspc/bool.cpp
http://lvp.com/data/cpluspc/bool.h
bool.h is required for string.h...
to use these headers just do:
the find function is overloaded, so you can have a character argument, or a string argument.Code:String test; //notice the capitalization
test = "hello";
int l = test.length(); // length function
cout << test.substr(0, l); //sub string function
cout << test.find("h"); //find function
If you are using MFC you can use the CString class.
CString strTemp;
strTemp = "HI";
Dennis(Benji :p ) what was the platform sdk you were talking about earlier?
Don't use CString - it has a reallocation bug :(
Use the STL string class <string> (make sure to have using namespace std; in there!)
The platform SDK is the greatest source of documentation in the world. It's at msdn.microsoft.com - choose "Downloads".
Didnt they fix that in SP3???
Parksie is it actually called "platform sdk"?
Chris:
Here is a link to download the Platform SDK
http://www.microsoft.com/msdownload/...uplauncher.htm
It's called the Platform SDK because it's information for developing apps for the Windows platform. It's the same meaning as in the phrase 'platform-independant'. SDK stands for software development kit (I think).
I think so, but it's just in case he doesn't have SP3 :)Quote:
Originally posted by Technocrat
Didnt they fix that in SP3???
Oh...for those using the STL classes and want to use Unicode, then this code snippet might help:
Both string and wstring are template implementations of the basic_string class. string uses the char type, and wstring uses the wchar_t type. Alternatively, you may wish to use:Code:#ifdef UNICODE
typedef String wstring;
#else
typedef String string;
#endif
Code:typedef String basic_string<TCHAR>;
Thanks :p
Er...Megatron...he wanted a dynamic string. (I see what you mean, but probably one where you didn't have to bother reallocating it yourself)Quote:
Originally posted by Megatron
You can also use the following to declare a string:
Code:char* MyString;