String to Char array?

This is a discussion on String to Char array? within the C++ Programming forums, part of the General Programming Boards category; Hey everyone, for a program I am writing, i need to convert a string of the class std::string to a ...

  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,796
    >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, 10:42 PM
  2. Replies: 8
    Last Post: 04-25-2008, 03:45 PM
  3. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 01:04 PM
  4. Character arrays
    By PsychoBrat in forum C++ Programming
    Replies: 7
    Last Post: 06-21-2002, 01:02 PM
  5. Strings are V important...
    By NANO in forum C++ Programming
    Replies: 15
    Last Post: 04-14-2002, 12:57 PM

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