[C++] String class...Can't find it
I've tried everything to get a string working. I can't seem to find ANY helpful information on the compiler or classes you can use.
I've tried the following:
#include <string>
#include <string.h>
#include <String>
#include <String.h>
None of those work when I try to declare a String:
String s;
It gives me an error saying String is undeclared.
I'm using the Bloodshed IDE by the way, and I looked at an example it came with and they used:
#include <string.h>
but that still doesn't work for me.
Am I doing something wrong? Is there any helpful documentation?
Re: [C++] String class...Can't find it
The C++ string class lives in the std namespace, you can use it with:
Code:
#include <string>
std::string my_string = "this is a string";
or:
Code:
#include <string>
using namespace std;
string my_string = "this is a string";
Re: [C++] String class...Can't find it
Thanks! That worked perfectly. I commented out using namespace std, so that was part of the reason I couldn't get it to work.
One more thing if you don't mind. I've got a really old book that I like to read(it's called Mastering C++ for pascal and c programmers), and it was using a capital S for string. Has this changed in the newer version of C++?
Re: [C++] String class...Can't find it
There never was a (standard) String class with a capital S. Maybe that book uses its own string class, or a speficic library.