Pelles C forum

C language => Beginner questions => Topic started by: ml1969 on March 22, 2009, 01:36:23 PM

Title: found 'char *', expected 'const wchar_t *'.
Post by: ml1969 on March 22, 2009, 01:36:23 PM
Hello,

waht I want to do ist qiuet simple  ::)...

I want to read one thing from txt. file
it looks like
\windows\explorer.exe  or something like that....

I do this with:

Code: [Select]
.....
FILE *f;
char zeile[80];
......

and

Code: [Select]
if ( ( f = fopen("\\Storage Card\\test.txt", "r" ) ) == NULL)
     {
     fgets(zeile, 80, f);
     fclose(f);
     }

now I want to use createprocess in this way

CreateProcess(zeile, NULL,0,0,FALSE,0, 0, 0, NULL, NULL);

but I get the error found 'char *', expected 'const wchar_t *'.

Ok I understand, but how can I solve it?


Michael

Title: Re: found 'char *', expected 'const wchar_t *'.
Post by: frankie on March 22, 2009, 01:50:33 PM
Michael,
you're programming on wince as I understand, for wince everything is unicode. The base character for unicode is a two bytes unit defined as wchar. So simply:
Code: [Select]
.....
FILE *f;
wchar zeile[80];
......

and

Code: [Select]
if ( ( f = fopen(L"\\Storage Card\\test.txt", "r" ) ) == NULL)
     {
     fgets(zeile, 80, f);
     fclose(f);
     }

Where the 'L' before the filename tells the compiler to encode the filename itself as unicode widechar.
Before continuing I suggest that you read some tutorial for wince programming. You'll find information in the smarthphone section of this blog and googling around.
Title: Re: found 'char *', expected 'const wchar_t *'.
Post by: ml1969 on March 22, 2009, 02:02:25 PM
HI,

you are right, I will programm for an WinCe Device,
and all other things will work
createprocess, terminateprocess, registry-" editing" etc....

at least I want to create a file like a ini oder txt file, which include only one parameter (path to file & file)
I want to read this file (it works)
I want to start the executeable with the createprocess-command.


And looking for the solution for a few days (msdn, google, etc...

Michael