string in .net 2005

Started by
7 comments, last by intransigent-seal 18 years, 5 months ago
i just switched to .net 2005 and i am getting depracted warnings. i know that the functions are different and i switched them in my program to be more secure via sprintf_s and strcpy_s. but, the string.h is having the warinings not my program. is there a different string class for .net 2005 that has the secure functions not the depracted functions? instead of #include <string> using namespace std; i know i am asking alot of questions lately but thats good, not bad. asking questions gains knowledge.
Advertisement
Just suppress that particular warning from the command line (or project options). If you know how to use those functions, they are no less secure than any other functions. You may want to take a look at each instance of the warning to make sure you're passing it good data, but then you can just suppress it.
enum Bool { True, False, FileNotFound };
You shouldn't be using those functions at all in C++ (or at least very rarely). You mentioned std::string (or at least you seem to know about it given that you mentioned #include <string>). Use std::string, and use its member functions. strcpy and friends are part of the C library (as opposed to the C++ library), and you shouldn't need to use them if you're using std::string.
sprintf is again part of the C library, and you should be using C++'s iostreams. If you need to format some text into a std::string instead of outputting it to a file or to the console, use std::stringstream (in the <sstream> header)

As for strcpy and co being deprecated - they're not. It's a Microsoft-only thing, as MS attempts to push people towards good C++ programming practices (and also towards .NET, I guess).

John B
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
Quote:Original post by JohnBSmall
It's a Microsoft-only thing, as MS attempts to push people towards good C++ programming practices.


Well people blame them for security issues so you can hardly blame them for trying to get people to be more secure.

----Erzengel des Lichtes光の大天使Archangel of LightEverything has a use. You must know that use, and when to properly use the effects.♀≈♂?
ok so how do i get rid of all the warnings?

where is the option to do that?
Quote:Original post by JohnBSmall
You shouldn't be using those functions at all in C++ (or at least very rarely).

Note that std::copy will also cause the same warning, at least when used on PoD types where it degrades to memmove (and possibly also on more complex types, I honestly haven't checked).
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Quote:Original post by 31337noob
ok so how do i get rid of all the warnings?

where is the option to do that?


i found it.

now i dont get the depracated messages
Quote:Original post by Promit
Quote:Original post by JohnBSmall
You shouldn't be using those functions at all in C++ (or at least very rarely).

Note that std::copy will also cause the same warning, at least when used on PoD types where it degrades to memmove (and possibly also on more complex types, I honestly haven't checked).

Oh? I didn't realise that. The basic point still stands though.

John B
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
Quote:Original post by Erzengeldeslichtes
Quote:Original post by JohnBSmall
It's a Microsoft-only thing, as MS attempts to push people towards good C++ programming practices.


Well people blame them for security issues so you can hardly blame them for trying to get people to be more secure.

I'm not blaming them - just trying to inform people who might not realise otherwise.

John B
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.

This topic is closed to new replies.

Advertisement