are Strings standard now?

This is a discussion on are Strings standard now? within the C++ Programming forums, part of the General Programming Boards category; Was just wondering if strings were made part of the c++ standard. I like working with char arrays even though ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    203

    are Strings standard now?

    Was just wondering if strings were made part of the c++ standard. I like working with char arrays even though it's more work, but if there is a standardized string now then i should probably learn it.

  2. #2
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    I think std::string has always been part of the C++ standard. Even if it hasn't, it is now.

    http://www.cprogramming.com/tutorial/string.html
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    7,328
    There has been only one C++ standard (from 1998). It included a specification for a standard library. That standard library includes a string class (called string). So, the string class is part of the C++ standard, and is therefore portable to all standards-compliant compilers.

    Technically speaking the string class isn't part of the language itself, it is implemented in terms of the C++ language, and can be implemented in many different ways by the library writers. However, it is still considered part of standard C++, so learning it is an excellent idea.

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    203
    So while it's not part of the C++ language, the string class will be the same for all compilers and platforms?

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    7,328
    Short answer: Yes.

    It is part of the standard library, which is part of the language standard. That means that any compiler that follows the C++ standard will provide the same guarantees that the standard gives. Basically you can use the string class and it will work on all modern compilers.

    It is the same as standard C library stuff like rand(), strlen(), memcpy(), etc. Those aren't keywords that are part of the actual language, but they are part of the standard library so you can use them on any standards conforming compiler.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Strings under the STL?
    By laserlight in forum C++ Programming
    Replies: 9
    Last Post: 07-19-2007, 02:55 AM
  2. Problems with strings as key in STL maps
    By all_names_taken in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 10:34 AM
  3. Help w/ comparings two strings case sensitive
    By ikkin in forum C Programming
    Replies: 7
    Last Post: 11-13-2003, 07:26 AM
  4. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM
  5. Table mapping Strings to Strings
    By johnmcg in forum C Programming
    Replies: 4
    Last Post: 09-05-2003, 11:04 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21