Question:
fopen function help?
anonymous
2008-05-16 12:55:33 UTC
I am using Visual Studio 2005 for my OOP class.

For one of the assignments, I have to open a file for reading.
I open a file for writing just to test out to see if fopen( ) works.

FILE *fp;
fp = fopen( "testFile.txt", "w" );

But it keeps generating this warning.

warning C4996: 'fopen' was declared deprecated
What is that mean?
Three answers:
anonymous
2008-05-16 17:52:32 UTC
This is Microsoft insanity (as usual). The use of fopen (and an entire family of other C functions) is NOT deprecated by the ANSI/ISO C/C++ standards. This is something MS took upon themselves to do. They ignored standards with their own version of Java and now they seem intent to do it with C/C++ too.



MS wants you to use functions like fopen_s() because it is safer. It no doubt is. The problem is that it will make your code complete non-portable to anything other than Windows. Sound familiar?



So your choices are (1) to use their "safe" functions OR (2) code proper C/C++ and use



#define _CRT_SECURE_NO_DEPRECATE



and/or



#define _CRT_NONSTDC_NO_DEPRECATE



in your source files or put them in your project settings



or (3) stop using MS's crappy compilers!!!
-- JuliuS -- d
2008-05-16 13:00:55 UTC
as far as i know deprecated means removed from use, removed from standards or something like that. maybe the syntax of that function was changed or that it has been removed. try looking for some other function
Got Security?
2008-05-16 13:00:05 UTC
it means they still support it, but it's not the preferred method anymore, try wfopen()


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...