LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-20-2006, 09:25 AM   #1
xfceslacker
LQ Newbie
 
Registered: Oct 2006
Posts: 2

Rep: Reputation: 0
Converting string to char


Hello,
The compiler I'm using is g++ 4.0.3. I want to convert a C++ string to char. The gtk_label_new() function takes a char, and I was using a string to get the value needed to put in the label. The function won't take a string so I need to convert that string to a char array.

Thanks
 
Old 10-20-2006, 09:42 AM   #2
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
I'm hoping you mean std::string and char *. std::string has a method called c_str() that does what you want. In the future, go read the docs. They are easy to find by googling "std::string"?
 
Old 10-20-2006, 05:15 PM   #3
xfceslacker
LQ Newbie
 
Registered: Oct 2006
Posts: 2

Original Poster
Rep: Reputation: 0
I'll do that in the future. Sorry I didn't think todo that first.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
python: converting a 3 character octal string into and ASCII char llama_meme Programming 1 07-06-2010 02:00 PM
converting char *........... dogslayer Programming 7 04-08-2006 09:22 PM
C++ converting from char to integer MicahCarrick Programming 4 12-19-2005 02:16 PM
C++ -> Converting strings to char* Dark Carnival Programming 1 01-25-2005 04:17 PM
C++: char* to string, converting? rewriting program? need substr! lrt2003 Programming 2 06-19-2004 03:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration