   Why does this error?
  I have this code:static int __index(lua_State* L) {int *Ptr = (int*)lua_topointer(L, -2);const char *ind = lua_tostring(L, -1);Triangle O = GetPointerObject(Ptr);if (ind == "Name") { // This line is what I think errorslua_pushstring(L, O.Name.c_str());}else {lua_pushnil(L);}return 1;}And when I run the program in debug I get an error like this:invalid null pointer   
  if(ind == "Name") compares pointers, not "strings." You are almost certainly going to take the false branch every time, because it's not doing what you want it to do.There are several places you could be dereferencing a null pointer, but it's impossible to say without more information. Step through the code in your debugger.   ;  How can I compare them then?   ;  Turn them into std::strings, or use strcmp.   ;  I am using std::string and it works now.  Thanks!   ;  Well I think you have to use string operator there not directly string there. The another thing is that you have not mention that which error message you are getting. If you got the error in that line than it should be proper to use string operator there.   