Thread: String to Char array?

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    11

    String to Char array?

    Hey everyone, for a program I am writing, i need to convert a string of the class std::string to a character array. So essentially i need to convert something of the form:

    string toBeConverted;

    into:

    char converted[];

    does anyone know if theres a function to do that or a method of doing that?

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >for a program I am writing, i need to convert a string of the class std::string to a character array
    *sigh* Call the c_str() member function of std::string and you'll get a C-style string. Take a look at my reply to your other thread asking this question.

    And don't be in such a rush.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  2. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  3. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM
  4. Character arrays
    By PsychoBrat in forum C++ Programming
    Replies: 7
    Last Post: 06-21-2002, 12:02 PM
  5. Strings are V important...
    By NANO in forum C++ Programming
    Replies: 15
    Last Post: 04-14-2002, 11:57 AM