Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » How to convert String to char ?
How to convert String to char ? [message #12498] Tue, 06 November 2007 03:26 Go to next message
LiniX is currently offline  LiniX
Messages: 7
Registered: October 2007
Location: Thailand
Promising Member
Hi,

i don't know how to convert Upp::String to char*. How to convert ?
(I use EditString to input to String a, I send String a to library function but library function is char* input, i don't know how to convert Upp::String to char*)

and/or

What String type is easy to convert? (String , WString ,etc..)

i am a very newbie.
(Sorry for stupid question)

Thank You
Watchara Kangkun
Re: How to convert String to char ? [message #12499 is a reply to message #12498] Tue, 06 November 2007 06:07 Go to previous messageGo to next message
andrei-catalin is currently offline  andrei-catalin
Messages: 62
Registered: May 2006
Location: Romania
Member
http://www.ultimatepp.org/forum/index.php?t=msg&th=36&am p;start=0&

Andrei
Re: How to convert String to char ? [message #12508 is a reply to message #12498] Tue, 06 November 2007 19:08 Go to previous messageGo to next message
LiniX is currently offline  LiniX
Messages: 7
Registered: October 2007
Location: Thailand
Promising Member
Thank you .

But library function in put is only char*,

How to change const char* to char* ? or can't ?

Thank you
Watchara Kangkun
Re: How to convert String to char ? [message #12511 is a reply to message #12508] Tue, 06 November 2007 21:15 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
LiniX wrote on Tue, 06 November 2007 13:08

Thank you .

But library function in put is only char*,

How to change const char* to char* ? or can't ?

Thank you
Watchara Kangkun


You cannot convert String to char *.

The reason is that String interface is created so that efficient reference counted implementation is possible. That excludes this kind of conversion.

If you need to write to String content, you can use StringBuffer though.

String x = "Fun";
StringBuffer sb = x;
char *s = ~sb;
s[1] = 'a';
x = sb;


Note that transfers between StringBuffer and String are very fast, as long as the reference count (if any) is 1.

(Note2: Current String implementation uses reference counting only for long Strings).

Mirek
Re: How to convert String to char ? [message #12540 is a reply to message #12511] Thu, 08 November 2007 03:03 Go to previous message
LiniX is currently offline  LiniX
Messages: 7
Registered: October 2007
Location: Thailand
Promising Member

Mirek ,Thank You Very Much


Watchara Kangkun
Previous Topic: XML , DOM - Modify the tree
Next Topic: Control with window handle
Goto Forum:
  


Current Time: Sat Apr 27 01:39:58 CEST 2024

Total time taken to generate the page: 0.04751 seconds