string class
string class
ok this question is not directly to do with irrlicht but i am just wondering why the string is not working with code::blocks
anyone else got this problem?
anyone else got this problem?
I had trouble with it, try this:
Code: Select all
#include <string>
using namespace std;
int main()
{
std::string sString = "Hello";
sString += " World";
return 0;
}
Well, I don't know what the problem really is, too...
But should the include not be like this:
But should the include not be like this:
Code: Select all
#include <string.h>
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
<string>Acki wrote:Well, I don't know what the problem really is, too...
But should the include not be like this:Code: Select all
#include <string.h>
and
<string.h>
Can both be used. However on most of the compilers I've used if you use the second one you get a warning about using antiquated headers.
For the OP the code you posted works just fine with my macine, what errors are you getting??
Actually, the two are not interchangeable.
You must #include <string> if you want to use the C++ Standard Library string classes [std::basic_string, std::string and std::wstring]. If you #include <string.h> you will get the Standard C Library string functions [strcmp, strstr, strchr, ...].
If the following compiles, the C libraries are not compliant.
The code posted originally is correct should most definitely compile. As we've all said, it would be nice to see an error message.
Travis
You must #include <string> if you want to use the C++ Standard Library string classes [std::basic_string, std::string and std::wstring]. If you #include <string.h> you will get the Standard C Library string functions [strcmp, strstr, strchr, ...].
If the following compiles, the C libraries are not compliant.
Code: Select all
#include <string.h>
std::string s;
Travis
ok i got it working with
but just one last (stupid) question: is it possible to have an array of strings? how?
and thanks for all the help [/code]
Code: Select all
#include <string>
using namespace std;
int main()
{
std::string sString = "Hello";
sString += " World";
return 0;
}
and thanks for all the help [/code]
-
- Posts: 377
- Joined: Fri Oct 28, 2005 10:28 am
- Contact:
BTW, you don't need both "using namespace std;" and "std::string". They're interexchangable. But if you omit the "using.." be sure to put "std::" infront of every string or whatever it is that you're using from the std namespace.Anonymous wrote:Code: Select all
using namespace std; std::string sString = "Hello";