C++ Pointer trouble with File I/O
I am writing a function that takes in a output target file and a couple of other arguments. I am currently having troubl开发者_JAVA百科e with converting types between the argument passed in and using it in the fopen_s() method.
FILE* outputf;
void myfunc(FILE* fin, CString finpath,...)
{
outputf = fopen_s(&fin, finpath, "w");
.......
}
I've been stuck on this for a while and could use some help on this one. I am developing in Visual Studio 2008
Thanks
Maybe you just have to cast CString
to LPCTSTR
:
outputf = fopen_s(&fin, (LPCTSTR)finpath, "w");
Looks like I found my answer. Turns out that fopen_S doesn't allow shared access to the FILE* specified for opening. I had to use _fsopen instead and that solced my problem!
精彩评论