+ 7

[SOLVED] how do i get rid of _CTR_SECURE_NO_WARNINGS on visual studio?

and editing the project properties will not work. idk y

19th Nov 2018, 9:23 PM
LONGTIE👔
LONGTIE👔 - avatar
9 odpowiedzi
+ 5
Did you change this FILE * fh = fopen("file.txt", "w"); to this FILE * fh; int error_number = fopen_s(&fh, "file.txt", "w"); and still, the compiler issues a warning?
22nd Nov 2018, 5:38 AM
Babak
Babak - avatar
+ 10
Manual i found that link too. the top answer dose not work. the second one dose... but its just a bit of a pain for everytime i need to work with files. I'm not sure what type of error.
21st Nov 2018, 3:48 AM
LONGTIE👔
LONGTIE👔 - avatar
+ 7
C++ Soldier (Babak) nope. I'll try that tommorow and see if that works.
22nd Nov 2018, 5:49 AM
LONGTIE👔
LONGTIE👔 - avatar
+ 6
C++ Soldier (Babak) the "secure" versions didnt work. or do i need include the #define ?
21st Nov 2018, 10:37 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 6
C++ Soldier (Babak) there is a bunch of codes ( it mainly happens when im dealing with the c standard library or files) this one https://code.sololearn.com/cw4E8rh41UiB/?ref=app
22nd Nov 2018, 5:19 AM
LONGTIE👔
LONGTIE👔 - avatar
+ 4
As the name of the directive suggests, it suppresses those types of "Warnings" which involve C runtime (CRT) security issues regarding language constructs. For example, in order to write some formatted data to a string, according to the documentation you have two primary choices (for un-wide chars): 1. sprintf (insecure version) 2. sprintf_s (secure version) If you choose the first one, you end up with the above suggestion (warning). So, again you have two choices to pick from: 1. change `sprintf` to `sprintf_s` 2. Define a suppress directive "before" any header like so #define _CRT_SECURE_NO_WARNINGS
21st Nov 2018, 8:00 AM
Babak
Babak - avatar
+ 4
If you are willing to identify the root of the problem, then it's probably much better to share your code with us for a close inspection, otherwise, you can make a detour by defining the aforementioned directive at the top of the program.
22nd Nov 2018, 5:15 AM
Babak
Babak - avatar
+ 2
Cannot say I am fimilsr with it. Linker error? Or compilation error?
20th Nov 2018, 9:16 PM
Manual
Manual - avatar