Skip to content
Snippets Groups Projects
Commit e90c40e4 authored by Tong Zhang's avatar Tong Zhang
Browse files

modify code

parent 16f2cdbe
No related branches found
No related tags found
No related merge requests found
No preview for this file type
#include <windows.h> #include <windows.h>
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
FILE* my_fopen(char *str, char *mode)
{
int nameNumber = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0 );
wchar_t m[nameNumber+1] ;
wchar_t *str1 = m;
int i = MultiByteToWideChar(CP_UTF8, 0, str, -1, str1, nameNumber);
str1[nameNumber] = L'\0';
int nameNumber2 = MultiByteToWideChar(CP_UTF8, 0, mode, -1, NULL, 0 );
wchar_t n[nameNumber2+1] ;
wchar_t *mode1 = n;
int j = MultiByteToWideChar(CP_UTF8, 0, mode, -1, mode1, nameNumber2);
mode1[nameNumber2] = L'\0';
return _wfopen(str1, mode1);
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
assert(argc==1); assert(argc==1);
/* Your code here. */ /* Your code here. */
char * srcFile = "马Häst马.txt"; wchar_t * srcFile = L"马Häst马.txt";
char * destFile = "win32.txt"; char * destFile = "win32.txt";
CreateFile( CreateFile(
"win32.txt", "win32.txt",
...@@ -41,8 +23,8 @@ int main(int argc, char **argv) ...@@ -41,8 +23,8 @@ int main(int argc, char **argv)
printf("copyFile src or dest file null !"); printf("copyFile src or dest file null !");
return 0; return 0;
} }
src = my_fopen( srcFile , "rb" ); src = _wfopen( srcFile , L"rb" );
dst = my_fopen( destFile, "wb" ); dst = fopen( destFile, "wb" );
if( NULL == src || NULL == dst ) if( NULL == src || NULL == dst )
{ {
printf("copyFile fopen failed !"); printf("copyFile fopen failed !");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment