您的位置:首页 > 编程语言 > C语言/C++

C++字符串比较

2013-06-13 19:39 127 查看
#include "IPerfomanceEstimate.h"
#include <iostream>
using namespace std;
using namespace PerfomanceEstimateService;
typedef struct tagPeople
{
public:
string strName;//名字
string strAddress;// 地址

}PEOPLE;
ostream & operator <<(ostream & os, const PEOPLE & people);
void main()
{

char strName[] = "ganquanfu";
int len = strlen(strName);
char *pName = (char *)malloc(sizeof(char)*(len + 1));
if (pName != NULL)
{
strcpy(pName, strName);
cout << pName << " " << "succeed" << endl;
}
else
{

cout << "fail" << endl;
}

if (strcmp(strName, pName) == 0)
{
cout << "Equal" << endl;
}
else
{
cout << "Not Equal " << endl;
}

int tem;
cin >> tem;
}
ostream & operator <<(ostream & os, const PEOPLE & people)
{
os << people.strName.c_str() << " " << people.strAddress.c_str();
return os;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: