c++ Error C4996 VisualStudioComunity15 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

c++ Error C4996 VisualStudioComunity15

Well, i have tried to combine 2 things in one, ive got some errors and solve them,but now im stuck... i cant compile the code because of this error... Those 2 things are 2 previous questions that i had on this site: 1) https://www.sololearn.com/Discuss/794515/how-can-you-output-something-as-a-superscript-and-subscript-in-c >>helped by Babak Sheykhan 2) https://www.sololearn.com/Discuss/815290/c-printing-the-correct-number-of-decimal-points-with-cout >>helped by Kinshuk Vasisht I have been reading about it in several places: https://stackoverflow.com/questions/19079482/error-c4996-std-copy-impl-function-call-with-parameters-that-may-be-unsafe https://stackoverflow.com/questions/38060411/visual-studio-2015-wont-suppress-error-c4996 Ive tried those ideas and couldnt figure it out what am i doing wrong, at some point i was getting more errors then the first place, so i belive i should let the code where i belive im doing smth wrong. IDE Visual Studio Community 2015 Here is the code with the issues: https://code.sololearn.com/c6b7m100D9Jv/#cpp Any solutions, ideas, or advice to change something(or to try different)...are welcome as always :)

5th Nov 2017, 3:57 PM
derXred
derXred - avatar
4 Answers
+ 4
Error C4996: Severity Code Description Project File Line Error C4996 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' ConsoleApplication14 c:\program files (x86)\microsoft visual studio 14.0\vc\include\xutility 2230 I have no idea what it is :D ive tried to go in xutility(line 2230): template<class _InIt, class _OutIt> inline _OutIt copy(_InIt _First, _InIt _Last, _OutIt _Dest) { // copy [_First, _Last) to [_Dest, ...) _DEBUG_RANGE_PTR(_First, _Last, _Dest); return (_Copy_impl(_Unchecked(_First), _Unchecked(_Last), _Dest, _Is_checked(_Dest))); //line 2230 } This is just over my head :))) Probably i will try to find another IDE-compiler and try with what you had :) even if it will be only for my knowledge.(i am tring to make a bigger project,maybe is going to help my CV). I want to get in the programming area :) even as an intern or smth, unpaid whatever, im still waiting for a call to an internship interview :) Dont judge, im just hoping...and if i get it soon it will be really big deal for me :( sry for the crying. Thank you for the responses! Have a great day! edit: i dont "give" you the mark as correct for a little bit :) i mean you check it and it works, but maybe i found the issue with this IDE that i use(is pretty good for me i belive,shows a lot of problems). I will wait a few days maybe and give the mark. :)
6th Nov 2017, 12:38 AM
derXred
derXred - avatar
+ 2
@derXred, I've used gcc on Linux and it worked. Probably the problem is related to some library differences. Not that my answer solves anything, I just posted it in hope it somehow helps to track the issue. Also, can you post a full error message here, maybe it will give some insight on what's wrong. And one thing you can try to localize the source of the problem - try commenting out chunks of code, and see if it compiles. Start of commenting out whole contents of the Print() function. Then uncomment parts of it and try to build. @~ swim ~ And my gcc didn't complain about a thing, even with -Wall...
5th Nov 2017, 9:38 PM
deFault
+ 1
I don't have Windows available to test this, but this code kind of works on Linux. The only issues were: - Line 22 #include "stdafx.h" should be commented - Line 145 wfout.open(L"Stats.txt"); should be changed to wfout.open("Stats.txt"); - Line 122 delete[] dno_char; results in segfault, so I commented it out too I'm really too lazy right now to figure out what the code does, but it outputs a file with the following contents: writable 1.002 dno_char s_convers 2 0.0004 4 1113 60.0010 1 4 320.5002 12 113 60.0010 1 1113 60.0010 writable 0.3 dno_char s_convers 1113 60.0010Line 1: Hello²! Line 2: O³ x₀ + x₁ + x₂ Line 3: x₃₊₄ Line 4: € Euro! Line 5: 2⁷⁻⁹ And if I change Line 160: std::cout << std::endl; to wfout << std::endl; , the outputs get a bit better IMO (in my text editor it looks more aligned than with this font): writable 1.002 dno_char s_convers 2 0.0004 4 1113 60.0010 1 4 320.5002 12 113 60.0010 1 1113 60.0010 writable 0.3 dno_char s_convers 1113 60.0010 Line 1: Hello²! Line 2: O³ x₀ + x₁ + x₂ Line 3: x₃₊₄ Line 4: € Euro! Line 5: 2⁷⁻⁹
5th Nov 2017, 8:29 PM
deFault
0
@Vincent Blankfield [LMGTFY] Yes the output is messy, because i wanted to see some values(im not so pro :D) and i wanted to combine the 2 codes and then make it nice for the eye..I dont know if is a good practice, but this is how i learn faster and understand more things. "Line 22 #include "stdafx.h" should be commented" -- that is a file auto-made when i create the project(PROBABLY here is the problem, but i could do other projects...i really dont know) "And if I change Line 160: std::cout << std::endl; to wfout << std::endl; " -- ive just miss that :) Ive tried all you said ,but is the same error... Probably is because of the IDE...are you using the same thing? Maybe i should try it on a different IDE...(maybe im saying something stupid). Thank you for the response! :)
5th Nov 2017, 9:25 PM
derXred
derXred - avatar