简体   繁体   中英

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 trouble 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

也许您只需要将CStringLPCTSTR

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM