In this a and “v1” does not come out to be equal…although the content is same..can someone help in suggesting a way such that a comes out to be equal to “v1”
int main()
{
stringstream s;
string a;
char *c="v1";
s<<c;
a=s.str();
cout<<a;
int i=strcmp(a, "v1");
cout<<"i="<<i;
}
On comparing a and “v1” do not come out to be equal…please suggest some way such that i may make a to be equal to “v1″…the end goal is to make a to be equal to “v1”.
Because
strcmpreturns 0 when the inputs match.(Incidentally, I assume that your actual code is
strcmp(a.c_str(), "v1"), because otherwise it wouldn’t have compiled.)