CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2002
    Location
    Boston, MA
    Posts
    335

    comparing std::string objects - no case

    Hi everyone. A quick STL question here: is there any function/method defined for case-insencitive comparesent of two std::string objects and if not - what would be the C++ way to convert std::string content to upper/lower case.

    I am very well aware of strupr, _tcsupr and other C fucntions that would allow me to do this but what would be the C++ way?

    Thanks a lot.

  2. #2
    Join Date
    Jul 2002
    Location
    Boston, MA
    Posts
    335

    Re: comparing std::string objects - no case

    Never mind folks. I found it:
    Code:
    std::transform(str.begin(), str.end(), str.begin(), toupper);
    If you have other suggestions please let me know. Thanks again.

  3. #3
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,725

    Re: comparing std::string objects - no case

    see my notes for some std::string utilities ...

    http://nicoletti.50megs.com/cpp_note...utilities.html

  4. #4
    Join Date
    Jul 2002
    Location
    Boston, MA
    Posts
    335

    Re: comparing std::string objects - no case

    Thanks, Philip! :-)

  5. #5
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588

    Re: comparing std::string objects - no case

    Nice collection of utilities Philip
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

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