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;
}
#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;
}
相关文章推荐
- 【工作记录】C++ 浮点数、字符串的比较
- 2013级C++第17周项目【项目2-用指针玩字符串】之字符串比较大小
- c++怎么比较5个字符串的大小并将其按从小到大输出
- 【转载,实用】c++拼接字符串效率比较(+=、append、stringstream、sprintf)
- C++中string类型与char*类型的字符串比较剖析
- C++实现strcmp字符串比较
- 请用c++ 实现stl中的string类,实现构造,拷贝构造,析构,赋值,比较,字符串相加,获取长度及子串等功能
- C/C++与Python字符串处理比较
- C++ strIcmp 字符串大小比较
- C++比较字符串的大小并且输出
- c++ 中字符串忽略大小写比较
- C++笔试题 字符串的比较,全排列,类似 和分解的问题
- C++中固定长度短字符串比较是否相同,忽略大小写比对时的小技巧
- c++拼接字符串效率比较(+=、append、stringstream、sprintf)
- c++实现字符串strcmp()大小比较
- C 和 C++ 字符串字面量的比较
- c++拼接字符串效率比较(+=、append、stringstream、sprintf)
- C++基础回顾-字符串地址比较
- C和C++中的字符串操作(比较详细)
- 关于字符数组和字符串比较 C++