wchar_t from char conversion problem
Posted: Mon Aug 23, 2004 5:04 pm
I know this is not realy about Irrlicht - but somehow it's connected because Irrlicht works on wchar_t types. And that couses my problems
I try to put text into structure like this:
struct Question
{
wchar_t question[1024];
wchar_t answer1[1024];
wchar_t answer2[1024];
...
};
from text file. It's done like this: (already have Question question[100] struct)
char buffer[1024];
int i =0;
ifstream questionfile ("questions.txt");
while (!questionfile.eof())
{
questionfile.getline (buffer, 100);
sprintf(question.question, 1024, L"Question: %s", buffer);
cout<<buffer<<endl;
...
i++;
}
I mean - this is simple code but I'm not very familiar with wchar_t because it doesnt work
I checked and rechecked questions.txt file, even removed it and created again (under windows, before that I had file created under linux). As I remember i worked under Linux.
On this computer I have winXP pro.
Part of code cout<<buffer<<endl; shows text properly on the console.
?? What am I doing wrong ??
I try to put text into structure like this:
struct Question
{
wchar_t question[1024];
wchar_t answer1[1024];
wchar_t answer2[1024];
...
};
from text file. It's done like this: (already have Question question[100] struct)
char buffer[1024];
int i =0;
ifstream questionfile ("questions.txt");
while (!questionfile.eof())
{
questionfile.getline (buffer, 100);
sprintf(question.question, 1024, L"Question: %s", buffer);
cout<<buffer<<endl;
...
i++;
}
I mean - this is simple code but I'm not very familiar with wchar_t because it doesnt work
I checked and rechecked questions.txt file, even removed it and created again (under windows, before that I had file created under linux). As I remember i worked under Linux.
On this computer I have winXP pro.
Part of code cout<<buffer<<endl; shows text properly on the console.
?? What am I doing wrong ??