How to compare a string with a string in pointer in c++
I am implementing linked list in c++. In that am trying to compare a data
stored in the node with a string. Here is my code:
String f;
cin>>f;
if(strcmp(temp->data,f)==0)
{ cout<<"same"; }
else
{ cout<<"not same"; }
Here is my error:
"assignment1.cc", line 160: Error: Cannot cast from std::string to const
char*.
"assignment1.cc", line 160: Error: Cannot cast from std::string to const
char*.
How to compare those two strings?
No comments:
Post a Comment