/* Wide characters in Addendum 1 for C90. */
#include <wchar.h>
#include <stdio.h>
int main() {
char line[100];
wchar_t str1[100], *str2 = L"hello world";
int retval,len;
strcpy(line, "hello");
len = strlen(line);
mbstowcs(str1, line, len);
retval = wcscmp(str1, str2);
if(retval > 0)
printf("str1 is greater than str2\n");
else if(retval == 0)
printf("str1 is identical to str2\n");
else if(retval < 0)
printf("str1 is less than str2\n");
else
printf("Error!\n");
}
The output is:
str1 is less than str2