CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Mar 2011
    Posts
    144

    trouble with strcmp

    so after trying awhile to compare a const char* to a string, I read that I'm supposed to compare using the strcmp method. But I'm still not getting a correct comparison to a string. While debugging, my text values look fine so I'm stumped. I'm trying to compare values in my std::map like so -

    Code:
    	for(std::map<Vector3DInt32,const char*>::iterator i = polys.begin(); i != polys.end(); i++) {
    		if(strcmp((*i).second,"Neighbor") == 0)  mywindow->appendText("[colour='FFFF0000']");
    		else  mywindow->appendText("[colour='FFFFFFFF']");
    		mywindow->appendText("{ ");
    		mywindow->appendText(Ogre::StringConverter::toString(Vector3((*i).first.getX(),(*i).first.getY(),(*i).first.getZ())));
    		mywindow->appendText(" }, ");
    	}
    I also tried using std::string and then comparing using

    if((*i).second.compare("Neighbor") == 0)

    but that is failing also...
    P.S. where is the code tag button?
    Last edited by Marc G; July 2nd, 2012 at 01:30 AM. Reason: Fixed code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured