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 » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » Invalid conversion
Re: Invalid conversion [message #7584 is a reply to message #7583] Sun, 07 January 2007 18:36 Go to previous message
mirek is currently offline  mirek
Messages: 13980
Registered: November 2005
Ultimate Member
String text = ....
const char *s = text;


(warning: s valid only till next mutating operation on text).

If you really need char[], you can also do this:

char h[...];
strcpy(h, text);


Anyway, beware, there is a danger of buffer overrun (if text.GetLength() is greater than sizeof(h) - 1.)

Alternative, without buffer overrun danger:

Buffer<char> h(text.GetLength() + 1);
memcpy(h, text, text.GetLength() + 1);

[Updated on: Sun, 07 January 2007 18:37]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Chip 8 Emulator
Next Topic: passing X11 mouse events in spawned process
Goto Forum:
  


Current Time: Tue May 28 12:24:15 CEST 2024

Total time taken to generate the page: 0.00721 seconds