Hello everybody.
I want to store user input in a string, but I have problems putting the string on the screen. This is my font->draw() function (where text is my string):
font->draw(L + text,core::rect<s32>(10,10,100,50),video::SColor(0,0,255,0));
The compiler says that 'L' is not identified. I've tried it with a few other notations too, but it doesn't work. Is there any way to get rid of the 'L' so you can just put the name of your string in the function?
Thanks in advance?
using strings with font->draw()
Are you thinking of L as in L""?
When a character array(string) has an L before it, that means that it is not a normal char, but a wide char (wchar_t).
So L"hiya" != "hiya".
You would have to use a conversion like mbstowcs()
When a character array(string) has an L before it, that means that it is not a normal char, but a wide char (wchar_t).
So L"hiya" != "hiya".
You would have to use a conversion like mbstowcs()
Code: Select all
#include <string.h>
char InText[255];
wchar_t OutText[255];
mbstowcs(OutText,InText,255);
Crud, how do I do this again?
I'm thinking about L like in the font->draw code. Just like this example:
font->draw(L"Hello World",core::rect<s32>(10,10,100,50),video::SColor(0,0,255,0));
Anyway, I want to try your solution, but the compiler says that
mbstowcs is an undeclared identifier. I've included the string.h file, but it keeps giving the error. What am I doing wrong?
font->draw(L"Hello World",core::rect<s32>(10,10,100,50),video::SColor(0,0,255,0));
Anyway, I want to try your solution, but the compiler says that
mbstowcs is an undeclared identifier. I've included the string.h file, but it keeps giving the error. What am I doing wrong?
Never mind about my last post. I've found the solution: you have to include <stdlib.h> in your project. Thanks for your help.
Now I've got another question. How would you make a console like in Quake or like DOS. I can't find a way to keep the previous typed letters in memory. I always have to redraw them (which doesn't really wanna work either).
Now I've got another question. How would you make a console like in Quake or like DOS. I can't find a way to keep the previous typed letters in memory. I always have to redraw them (which doesn't really wanna work either).