How to copy/convert a char string to a wchar_t string in C? -


i looked around, , found program swprintf used <wchar.h> library. tried method, , didn't work. says program.exe has stopped working when run program. copied sample program found, own compiler-- didn't work either. i'll copy program below:

#include <stdio.h> #include <wchar.h>  int main(void) {   wchar_t namebuffer[100];  char *str1 ="c:\\program files\\test.txt";     swprintf(namebuffer,100,l"%s",str1);    printf("%s\n",namebuffer);    return 0; } 

is there wrong code or compiler?

try converting mbstowcs():

#include <stdio.h> #include <wchar.h> #include <stdlib.h>  int main(void) {   wchar_t namebuffer[100];  char *str1 ="c:\\program files\\test.txt";     mbstowcs(namebuffer, str1, 100);    wprintf(l"%ls\n",namebuffer);    return 0; } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -