Click to See Complete Forum and Search --> : cannot convert from 'const wchar_t *' to 'const char *'


sublime99
March 6th, 2008, 10:41 AM
Hello,
I have a unicode app which needs to send a file name to this function. This function only accepts char *

Is there a graceful way to handle this please?

int getJFile(const wchar_t * fname, std::vector<int>* p )
{
if ((infile = fopen(fname, READ_BINARY)) == NULL) {
exit(EXIT_FAILURE);
}

/* Scan the File. */
(void) scan_File( p );

return sizeof(p);
/* All done. */


}

MikeAThon
March 6th, 2008, 11:11 AM
If this is Windows, then look at the WideCharToMultiByte() function.

Mike

sublime99
March 6th, 2008, 12:14 PM
Hello,

Thank yo for your response. I am aware of this function. I would like to find a more elegant solution perhaps involving a stringstream. Is it possible?

0xC0000005
March 6th, 2008, 05:01 PM
_wfopen()

MikeAThon
March 6th, 2008, 09:09 PM
Looking at your answer, I'm smacking my forehead with a "duh". Thanks for pointing out the simple solution, instead of my contrived one.

sublime99
March 7th, 2008, 02:15 PM
perfect. thank you