Strings in C++?
I'm new here, so please don't be so harsh on me hehe.
So basically, I went out and purchased "C++ For Dummies, 5th Edition", and read the variables section. It says for strings, you use it in the following format:
However, when I put this in, I get a compiler error. I don't think string is recognised as a variable type because it doesn't get highlighted.
So I was wondering, what's going on? Does C++ even support strings? Is there some sort of different header apart from the iostream I need to include?
Oh, happy new year everyone, hope you've all had an excellent Christmas.
You need to #include <string>. Also, unless you have a using directive like using namespace std; or a using declaration like using std::string;, you should fully qualify the name as std::string.
Thanks a lot!
Originally Posted by laserlight
Have an excellent new year.
The cool thing about strings are that you can even access individual characters like char string arrays, like so: szString[i];
If you need to convert to char array: szString.c_str();
And if you need to cut up sections, use .substr()!
That's not cool, that's the biggest headache in trying to produce a std::string-compliant proper unicode-based string implementation.