|
-
Dec 12th, 2000, 11:03 AM
#1
Thread Starter
Addicted Member
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
-
Dec 12th, 2000, 02:45 PM
#2
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:
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
the find function is overloaded, so you can have a character argument, or a string argument.
-
Dec 12th, 2000, 07:17 PM
#3
Frenzied Member
If you are using MFC you can use the CString class.
CString strTemp;
strTemp = "HI";
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Dec 13th, 2000, 11:39 AM
#4
Thread Starter
Addicted Member
Dennis?
Dennis(Benji ) what was the platform sdk you were talking about earlier?
-
Dec 13th, 2000, 06:40 PM
#5
Monday Morning Lunatic
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".
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Dec 14th, 2000, 10:48 AM
#6
Frenzied Member
Didnt they fix that in SP3???
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Dec 14th, 2000, 12:17 PM
#7
Thread Starter
Addicted Member
Parksie?
Parksie is it actually called "platform sdk"?
-
Dec 15th, 2000, 08:12 AM
#8
-
Dec 15th, 2000, 08:20 AM
#9
Frenzied Member
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).
Harry.
"From one thing, know ten thousand things."
-
Dec 15th, 2000, 01:46 PM
#10
Monday Morning Lunatic
Originally posted by Technocrat
Didnt they fix that in SP3???
I think so, but it's just in case he doesn't have SP3 
Oh...for those using the STL classes and want to use Unicode, then this code snippet might help:
Code:
#ifdef UNICODE
typedef String wstring;
#else
typedef String string;
#endif
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:
typedef String basic_string<TCHAR>;
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Dec 15th, 2000, 01:54 PM
#11
Thread Starter
Addicted Member
Thanks
Thanks
-
Dec 15th, 2000, 01:57 PM
#12
Monday Morning Lunatic
Originally posted by Megatron
You can also use the following to declare a string:
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)
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|