wcscpy ;wcscmp

[code=cpp]

/* STRCMP.C */
#include <string.h>
#include <stdio.h>

wchar_t string1[] = L"The quick brown dog jumps over the lazyfox";
wchar_t string2[] = L"The QUICK brown dog jumps over the lazyfox";
/*
int wcscmp( const wchar_t *string1, const wchar_t *string2 );
*/
void main( void )
{
	wchar_t tmp[20];
	int result;
	/* Case sensitive */
	wprintf( L"Comparestrings:\n\t%s\n\t%s\n\n", string1, string2 );
	result = wcscmp(string1, string2 );
	if( result > 0 )
	//strcpy( tmp, "greater than" );
	/*wchar_t * wcscpy(wchar_t *,const wchar_t *);*/
	wcscpy(tmp,L"greater than");
	else if( result < 0)
	//strcpy( tmp, "less than" );
	wcscpy(tmp,L"less than");
	else
	//strcpy( tmp, "equal to" );
	wcscpy(tmp,L"equal to");

	wprintf(L"\tstrcmp: String 1 is %s string 2\n", tmp );
	
	/* Case insensitive(could use equivalent _stricmp) */
	/*
	result = _stricmp(string1, string2 );
	if( result > 0 )
	strcpy( tmp, "greater than" );
	else if( result < 0)
	strcpy( tmp, "less than" );
	else
	strcpy( tmp, "equal to" );
	printf("\t_stricmp: String 1 is %s string 2\n", tmp );
	*/
}
/*
Comparestrings:
        The quick brown dog jumps over the lazyfox
        The QUICK brown dog jumps over the lazyfox

        strcmp: String 1 is greater than string 2
Press any key to continue
*/
[/code]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值