Converting String to Char Array

This is a discussion on Converting String to Char Array within the C++ Programming forums, part of the General Programming Boards category; I'm using VC++ 2005 EE. I have a win32 form with a text box and I want to convert the ...

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    6

    Converting String to Char Array

    I'm using VC++ 2005 EE.

    I have a win32 form with a text box and I want to convert the text from that text box into an array of char's

    Kind of like
    Code:
    TCHAR* s[1] = {"Hello World!"};
    But I want to do
    Code:
    TCHAR* s[1] = {txtBox->Text};
    I've tryed fiddling around with a few things like txtBox->Text->ToCharArray() and using strcpy but I couldn't get them to work.

    Thanks for any help.
    Last edited by Tanner.B; 04-06-2007 at 10:55 PM.

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    http://www.cppreference.com/cppstring/c_str.html

    assuming your talking about standard c++ 'string's and 'char*'s

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >I've tryed fiddling around with a few things like txtBox->Text->ToCharArray() and using strcpy
    Probably something like:
    Code:
    TCHAR s[100];
    strcpy(s, txtBox->Text->ToCharArray());
    Or whatever the tchar version of strcpy() is.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. converting string to integer, for further use
    By shoobsie in forum C Programming
    Replies: 2
    Last Post: 07-01-2005, 04:12 AM
  2. error converting string to char array
    By COBOL2C++ in forum C++ Programming
    Replies: 6
    Last Post: 07-11-2003, 11:59 AM
  3. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 09:31 AM
  4. Character arrays
    By PsychoBrat in forum C++ Programming
    Replies: 7
    Last Post: 06-21-2002, 01:02 PM
  5. Converting const char to char array
    By HomerJ in forum C++ Programming
    Replies: 4
    Last Post: 04-30-2002, 04:21 PM

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