Passing a filename to f.open()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sebouh
    New Member
    • Feb 2007
    • 77

    Passing a filename to f.open()

    Hi all.
    I'm having problems with this functions.
    I want to read from a file where the filename is in argv[1] of main. I can't seem to pass a char*, i need a const wchar_t *. Can anyone tell me how can i deal with this? I've been searching google for more than an hour and can't find how to convert char* to wchar_t, or anythign that helps.

    thanks alot.
  • askcq
    New Member
    • Mar 2007
    • 63

    #2
    are u trying to write into a file ....something like that ...

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Check this out:

      char *orig = "Hello, World!";
      cout << orig << " (char *)" << endl;

      // Convert to a wchar_t*
      size_t origsize = strlen(orig) + 1;
      const size_t newsize = 100;
      size_t convertedChars = 0;
      wchar_t wcstring[newsize];
      mbstowcs_s(&con vertedChars, wcstring, origsize, orig, _TRUNCATE);
      wcscat_s(wcstri ng, L" (wchar_t *)");
      wcout << wcstring << endl;

      mbstowcs is part of stdlib.h

      Comment

      Working...