Thread: What is the best string class to use?

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    411

    What is the best string class to use?

    and why?

    I usally use sprintf with a charcter array, what is a comparable function in the string class?

  2. #2
    Registered User
    Join Date
    Jul 2003
    Posts
    15
    It is my understanding that there is a sprintf for use in C++ also, but its in stdio.h
    and it has the same function as with C


    here is a site:

    http://www.cplusplus.com/ref/cstdio/sprintf.html

  3. #3
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    If you want to stay to a portable way of coding, std::string is the way to go. I don't know what it's formatting powers are though.

    If you are using Windows and MFC, CString is your friend. It has a Format function that takes exactly the same parameters like printf.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  4. #4
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,090
    Use stringstreams for formatting with the standard string class. They use the '<<' operator so you don't have to specify format arguments.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. String Class
    By BKurosawa in forum C++ Programming
    Replies: 117
    Last Post: 08-09-2007, 01:02 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 09:11 AM
  4. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  5. class object manipulation
    By guda in forum C++ Programming
    Replies: 2
    Last Post: 10-09-2004, 10:43 AM