CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: split string !!

  1. #1
    Join Date
    Mar 2007
    Posts
    9

    Unhappy split string !!

    plez...anybody can solve my problem?
    how to split a string into smaller pieces in c++ programming... like a string "school" .. i want to split this string to be "hool" only...
    Last edited by enaz; March 23rd, 2007 at 10:36 PM. Reason: for my final project

  2. #2
    Join Date
    May 2005
    Posts
    364

    Re: split string !!

    Use Mid function in CString class.

    I think you should have a thorough understanding on CString and string.h functions
    Dan

  3. #3
    Join Date
    Oct 2005
    Location
    Bangalore
    Posts
    1,051

    Re: split string !!

    Quote Originally Posted by danandu
    I think you should have a thorough understanding on CString and string.h functions
    not necessary, if he does not intend to use CStrings of Strings.
    - Sreehari
    "Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
    " Everybody is sent to Earth on a purpose. I am so Lagging behind that i won't die." – Calvin

  4. #4
    Join Date
    Mar 2007
    Posts
    9

    Unhappy Re: split string !!

    so, how can i do?

  5. #5
    Join Date
    Mar 2007
    Posts
    9

    Re: split string !!

    it's it true?


    string text = "school";
    string fragment = text.substr (2, 4);.

  6. #6
    Join Date
    May 2005
    Posts
    364

    Re: split string !!

    The Standard C++ library provides two specializations of this template class, with the type definitions string, for elements of type char, and wstring, for elements of type wchar_t.

    Pl read the msdn on string in c++
    Dan

  7. #7
    Join Date
    Mar 2007
    Posts
    9

    Wink Re: split string !!

    i got it!!

    main() {

    string text = "i got it!!";
    string fragment = text.substr (6,4);

    cout<< text << "= ";
    cout<< fragment <<endl; ;

    return 0;
    }

    output ;
    i got it!!= it!!


    thanks for everybody..
    Last edited by enaz; March 24th, 2007 at 03:32 AM.

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

Featured