string type understandment (beginner)

This is a discussion on string type understandment (beginner) within the C++ Programming forums, part of the General Programming Boards category; Hi, I am using functions which need a wchar_t* like the setText method of a TextBox Code: label.setText(myCaption); As I ...

  1. #1
    Registered User
    Join Date
    Jun 2009
    Location
    Germany
    Posts
    4

    string type understandment (beginner)

    Hi,

    I am using functions which need a wchar_t* like the setText method of a TextBox
    Code:
    label.setText(myCaption);
    As I want to be able to append a string to myCaption earlier, I am wondering which string type I should use to store it in a variable. I found only complex ways to do this with the wchar_t type. Would it be easier to store it as another type and then convert it to a wchar_t?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,775
    Perhaps you should use a std::wstring, then use the c_str() member function when you want to call setText().
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 10:03 PM
  3. Compile Error that i dont understand
    By bobthebullet990 in forum C++ Programming
    Replies: 5
    Last Post: 05-05-2006, 09:19 AM
  4. Replies: 6
    Last Post: 04-21-2006, 08:49 PM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM

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