#comparing graph element to string

13 messages · Page 1 of 1 (latest)

bitter bluff
#

The following code with the strcmp and == comparison does not work, any other ideas?

  //top row
  for (int c=0; c<col; c++){
    if (strcmp(graph[0][c], "O") == 0){
      q.push({int(0), c});
    }
  }

  //left col
  for (int r=0; r<row; r++){
    if (graph[r][0] == "O"){
      q.push({r, int(0)});
    }
  }
hasty portalBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.

bitter bluff
#

here is console output for more details

odd sable
#

replace the double quotes with single quotes

#

and don't use strcmp to compare chars (it's in the name)

#

also from the title it seems like you want strings

#

std::string is the "string" you'd expect from other languages

#

so try to avoid c styled strings (array of chars) unless you specifically need it

bitter bluff
#

Not sure how replacing it with single quote worked but thanks lol

#

!solved

hasty portalBOT
#

Thank you and let us know if you have any more questions!

#

[SOLVED] comparing graph element to string

hasty portalBOT
#

@bitter bluff

This question thread is being automatically marked as solved.