   That annoying warning
  The warning is:[Warning] address of local variable `char_str' returned The code is:const char* TextLine::GetMessage(void){int tempInt = message.length();   char char_str[tempInt];    for(int i=0; i< tempInt; i++) {  char_str = message;    }return char_str; };The code which needs the const char* is some deep code I don't understand, therefore I don't know how to recode their stuff. I've tried to make char_str a pointer but that causes an error.message is a std::string:std::string message;How do I get rid of this warning? Any links would be appreciated. Thank you in advance
  I'm having a hard time understanding how the warning is important right now, when that doesn't even compile.But heed the warning; it's warning you about a pretty severe bug. The value you return from that function is a pointer onto the stack.Incidentally : message.c_str().   ;const char* TextLine::GetMessage(void) const {return message.c_str();};EDIT:Ninja'd due to slow internet :(   ;  Yes, I'm ware warnings are possible bug causing problems later, so I wanted to fix it before I get too much further away from understand what the code does.It does compile with that warning and runs.  Your comment leaves me scratching my head. I think I might understand buffers and stacks and piles, and stuff after my next semester in college.;  _FastCall:Sweet!!! Perfict, that worked.Is there a link you would recommend for learning more about const?  That always something no one has really focused/taught about.Thank you, I'll be rating you :)   ;  You're welcome ;)You can read all about being const-correct here:  Const correctness.(More specifically 18.10)   ;Quote:It does compile with that warning and runs.  Then I wonder what compiler you're using, because that is not legal C++. The size of an array must be constant at compile time.   ;  DevC++ by BloodShed.net   ;Quote:Original post by DeyjaQuote:It does compile with that warning and runs.  Then I wonder what compiler you're using, because that is not legal C++. The size of an array must be constant at compile time.Interesting. I was always under the impression that it was allowed in C++, but not C (dunno why, probably because it looks more advanced. Yeah yeah, stupid, I know). It is allowed in C99 though, and GCC accepts it when compiling C++ code. Are there any other compilers that behave in the same way?   ;Quote:Original post by DeyjaThen I wonder what compiler you're using, because that is not legal C++. The size of an array must be constant at compile time.This is allowed in C++... Don't know where you got your facts from... @BladeStone, Dont use Dev-C++ its old as crap.. Look at MS Visual Stuidos (windows) or for a portable approch Netbeans or eclipse are good IDE's (I use netbeans on linux when I feel like using a ide)   