   C++ OpenGL/GLUT String.length() problem
  I'm working with strings, with C++ and openGL with GLUT.Supposely <string>.length() will return an int of the length of the <string> so I could have...#include<string>...std::string myString = "This is a string";int len = myString.length(); but the compiler says, length() is not defined.Does string and GLUT not work together much like #include <iostream>'s std::cout doesn't work with openGL?Thank you in advance,BladeStone   
  Can include the complete error message that you get? I would also suggets you try to trim your source code so that it's just enough to demonstrate the problem you're having, and post that as well (typically, just doing that will probably help you to figure out the problem on your own..)   ;  The error message is this:163 C:\Code\Dev-Cpp\WolfCrown\LengthIssues\main.cpp `length' has not been declared I can't show the whole thing, because to get it to just compile would be a few hundred lines, but I've narrowed it down to the following code. You can stick this code into a GLUT templet app, (before main of course, and after #include<string>) and you get the message.#include <string> // this is in the include tooclass TextLine {  private:std::string *message;    int maxMessageLength, currentMessageLength;  public:TextLine(int maxMessLen = 128, int curMessLength=0) {maxMessageLength = maxMessLen; currentMessageLength = curMessLength; message = new std::string[maxMessageLength];  // length is in line length}~TextLine(void) {;}    // returns the content of the line    const char* GetMessage(void); void AddMessage(std::string mess) {};void IncreaseMessageSize(void) {};};const char* TextLine::GetMessage(void){ const char* char_str; // = message;/* line 163 */for(int i=0; i< message.length(); i++) { //maxMessageLength  // stuff goes here}return "Stuff"; };   ;Quote:Original post by BladeStonestd::string *message;...message = new std::string[maxMessageLength];  // length is in line length...for(int i=0; i< message.length(); i++)OK, you've created a pointer to an std::string in the first line I've quoted, then you've assign an array of std::strings to it, then you're trying to call "length()" on a pointer to std::strings in the third line.You want to just create one string for the message, like so:std::string message;...message = "some string";...for(int i = 0; i < message.length(); i++) {;  the complexity is so I can have a dynamic array length ... but I .... might have added it to the wrong spot.Thank you for your help. I'll see if this resolution solves the bigger problem. (not posted due to size)   ;  Yep, I misplaced where I needed to make a dynamic array.  Thank you!This was the last hurdle before getting the mess to compile and to work right!   ;Quote:Original post by BladeStoneThe error message is this:163 C:\Code\Dev-Cpp\...I see a problem right there. You should really use Visual Studio.