how to convert char array to wchar_t array?

后端 未结 3 2030
情书的邮戳
情书的邮戳 2020-12-10 14:27
char cmd[40];
driver = FuncGetDrive(driver);
sprintf_s(cmd, \"%c:\\\\test.exe\", driver);

I cannot use cmd in

sei.lpF         


        
3条回答
  •  无人及你
    2020-12-10 15:04

    From your example using swprintf_s would work

    wchar_t wcmd[40];
    driver = FuncGetDrive(driver);
    swprintf_s(wcmd, "%C:\\test.exe", driver);
    

    Note the C in %C has to be written with uppercase since driver is a normal char and not a wchar_t.
    Passing your string to swprintf_s(wcmd,"%S",cmd) should also work

提交回复
热议问题