读书人

字符串是tcharfStream.write如何写?

发布时间: 2013-03-06 16:20:31 作者: rapoo

字符串是tchar,fStream.write怎么写?报错啊



TCHAR PathTemp[MAX_PATH];
。。。。。。。
//fStream.write("\\",1);
fStream.write(PathTemp,wcslen(PathTemp));
fStream.write("\r\n",2);


F:\code\3.4\SearchFiles\SearchFiles.cpp(96) : error C2664: 'write' : cannot convert parameter 1 from 'unsigned short [260]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
执行 cl.exe 时出错.
[解决办法]
FILE *f;
...
_ftprintf(f,_T("%s\n"),PathTemp);

[解决办法]
wfstream?
[解决办法]
reinterpret_cast<const char *>(PathTemp
[解决办法]
With MSVC (and thus the Microsoft STL), a constructor for filestreams is provided which takes a const wchar_t* filename, allowing you to create the stream as:

wchar_t name[] = L"filename.txt";
std::fstream file(name);

读书人网 >C++

热点推荐