C++字符串比较


#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;

}

posted @ 2013-06-13 19:39  Predator  阅读(210)  评论(0编辑  收藏  举报