Sunday, 11 August 2013

std::string vs char[] vs char*

std::string vs char[] vs char*

I know this question was asked before, but everyone seems to have a
different opinion about it. It's still very confusing, after reading SO
posts too.
Bjarne Stroustrup, the creator of C++, recommends in his book to
Prefer strings over C-style strings (a char*)
Many programmers these days still use char arrays and C style strings,
despite std::string being more intuitive and usable. They say they don't
need most of the functionality that std::string has.
But is it really that much overhead? This seems to be more relevant in
games development, so does that mean that a lot more resources are needed
for strings and that it could affect the frame rate?

No comments:

Post a Comment