69,322
社区成员
发帖
与我相关
我的任务
分享
TCHAR * pStr = _T("A01,2,3|货位编码~可存数量~已存数量^货位编码~可存数量~已存数量^货位编码~可存数量~已存数量");
int len = _tcslen(pStr);
char * p1 = new char(len*2 + 2);
//char p1[200];
memcpy(p1, pStr, len*2);
FILE * fp = fopen("Write_File.dat", "w+b");
if (!fp) return;
fseek(fp, 0, SEEK_SET);
int n = 0;
n = fwrite(p1, sizeof(char), len*2, fp);
fseek(fp, 0, SEEK_SET);
char * p2 = new char(500);
n = fread(p2, sizeof(char), len*2, fp);
fclose(fp);
// ...
fopen supports Unicode file streams. To open a Unicode file, pass a ccs flag that specifies the desired encoding to fopen, as follows.
fopen(&fp, "newfile.txt", "rw, ccs= encoding ");
char * p1 = new char[len*2 + 2];