[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]