Reading edit box text into a char*

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Mercior
Posts: 100
Joined: Tue Feb 24, 2004 1:53 am
Location: UK
Contact:

Reading edit box text into a char*

Post by Mercior »

I am trying to read the text of an edit box GUI element into a char * from the wchar * but having troubles.. Im trying to use this:

Code: Select all

			char tmps[128];
			
			sprintf(tmps, "%s", cNPCSpawner.spawncount->getText());
This just prints the first character of the edit box into the char *. Any ideas?
Spidla
Posts: 31
Joined: Tue Nov 25, 2003 3:46 pm
Location: Czech Republic
Contact:

Post by Spidla »

Try this :

Code: Select all

#define CHAR_SIZE 20
char *ResultChar = new char[CHAR_SIZE];
wcstombs(ResultChar,WideString,CHAR_SIZE);
It is working without problems
Mercior
Posts: 100
Joined: Tue Feb 24, 2004 1:53 am
Location: UK
Contact:

Post by Mercior »

Perfect! Thanks very much :)
Post Reply