Results 1 to 12 of 12

Thread: Char Strings []

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217
    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
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  2. #2
    Guest
    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.



  3. #3
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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


  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    Dennis?

    Dennis(Benji ) what was the platform sdk you were talking about earlier?
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  6. #6
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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


  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    Parksie?

    Parksie is it actually called "platform sdk"?
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  8. #8
    Guest
    Chris:

    Here is a link to download the Platform SDK


    http://www.microsoft.com/msdownload/...uplauncher.htm

  9. #9
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    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."

  10. #10
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    Thanks

    Thanks
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  12. #12
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Originally posted by Megatron
    You can also use the following to declare a string:
    Code:
    char* MyString;
    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
  •  



Click Here to Expand Forum to Full Width