I just hate the string header, I dont see the point of using it... can anyone give me reasons why I should use it? I just use an array of char...
Is it just me or is it common to do this?
Started by davidthefat, May 06 2009 02:32 PM
3 replies to this topic
#1
Posted 06 May 2009 - 02:32 PM
|
|
|
#2
Posted 06 May 2009 - 05:40 PM
Buffer overflows. They happen with array of char. They don't happen with string.
#3
Posted 07 May 2009 - 06:05 PM
That, and you can use istringstream on them to store string representations of floats, ints, and such - and it expands to meet your needs. Otherwise you have to do a whole lot of malloc, realloc, and sprintf calls, which, as WingedPanther mentioned, can result in buffer overflows. What exactly do you hate about the string class?
#4
Posted 08 May 2009 - 07:43 AM
If you get into the standard library, you'll find that there are a LOT of powerful features in the string class that you would have to hand craft for char arrays. Besides, you can access elements of a string as if it were an array of char, so you aren't losing much. I suspect your issue with std::string is you don't feel like you're "in control" of it, somehow. The reality is that it is safer, so no need for "control" of stupid stuff.


Sign In
Create Account


Back to top









