/////////////////////////////////不相等////////////////////////////////////
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
//#include <iostream>
//using namespace std;
int main(void)
{
wchar_t* cstr;
wchar_t* ptem = L"1";
wchar_t ptem1[] = {L"1"};
cstr = ptem1;
if (ptem == cstr)
{
printf("相等\n");
printf("ptem=%d,len=%d,sizeof=%d,cstr=%d,len=%d,sizeof=%d",ptem,wcslen(ptem),sizeof(ptem),cstr,wcslen(cstr),sizeof(cstr));
}
else
{
printf("不相等\n");
printf("ptem=%d,len=%d,sizeof=%d,cstr=%d,len=%d,sizeof=%d",ptem,wcslen(ptem),sizeof(ptem),cstr,wcslen(cstr),sizeof(cstr));
}
printf("\n");
system("pause");
return 0;
}
/////////////////////////////////不相等////////////////////////////////////
/////////////////////////////////相等////////////////////////////////////
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
//#include <iostream>
//using namespace std;
int main(void)
{
wchar_t* cstr;
wchar_t* ptem = L"1";
wchar_t ptem1[] = {L"1"};
cstr = ptem1;
if (0 == wcscmp(ptem,cstr))
{
printf("相等\n");
printf("ptem=%d,len=%d,sizeof=%d,cstr=%d,len=%d,sizeof=%d",ptem,wcslen(ptem),sizeof(ptem),cstr,wcslen(cstr),sizeof(cstr));
}
else
{
printf("不相等\n");
printf("ptem=%d,len=%d,sizeof=%d,cstr=%d,len=%d,sizeof=%d",ptem,wcslen(ptem),sizeof(ptem),cstr,wcslen(cstr),sizeof(cstr));
}
printf("\n");
system("pause");
return 0;
}
/////////////////////////////////相等////////////////////////////////////
wcscmp是内容比较
==是地址比较
显然字符串比较一般是判断内容是否相同,而不是存储地址是否相同
显然ptem,cstr两个字符串的内容是相同的,但是两个不同的存储地址