string Comparison
Posted
by muhammad-aslam
on Stack Overflow
See other posts from Stack Overflow
or by muhammad-aslam
Published on 2010-04-23T18:07:00Z
Indexed on
2010/04/23
18:13 UTC
Read the original article
Hit count: 362
I want to compare two user input strings, but not able to do so...
#include "stdafx.h"
#include "iostream"
#include "string"
using namespace std;
int _tmain(int argc, _TCHAR* argv0[])
{
string my_string;
string my_string2;
cout<<"Enter string"<<endl;
cin>>my_string;
cout<<"Enter 2nd string"<<endl;
cin>>my_string2;
cout<<my_string<<" "<<my_string2;
strcmp(my_string,my_string2);
int result;
result= strcmp(my_string,my_string2);
cout<<result<<endl;
return 0;
}
This error is appearing. Error 1 error C2664: 'strcmp' : cannot convert parameter 1 from 'std::string' to 'const char *' c:\users\asad\documents\visual studio 2008\projects\string\string\string.cpp 23 String
© Stack Overflow or respective owner