I used to make fopen safer with this code
fin = fopen(ifp, "r");
fout = fopen(ofp, "w");
if ((fin == NULL)||(fout == NULL))
printf ("Error opening files");
else {} //action
Now I moved to Microsoft Visual Studio 2013. It asks me to use fopen_s instead of fopen. Is there any solution other than using _CRT_SECURE_NO_WARNINGS? I mean, is the fact of filepath input (scanf) compatible with fopen_s? Or just forget it and disable security warnings?
P. S. I know that filepath input can be unsafe but I just have to do it this way, because it is stated so in my task.
I don't think this makes it safer. This is just good handling of conditions and what you should be doing. Probably should check
errnotoo.That being said, if you have the ability to use
fopen_s, then I would use it. From MSDN on the "security enhancements":