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;

}

原文链接: https://www.cnblogs.com/ganquanfu2008/archive/2013/06/13/3134536.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    C++字符串比较

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/92036

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月10日 上午1:28
下一篇 2023年2月10日 上午1:28

相关推荐