• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Uses various wchar_t * functions that have hand written SSE assembly
2 // implementations in glibc. wcslen, wcscpy, wcscmp, wcsrchr, wcschr.
3 
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <wchar.h>
7 
main(int argc,char ** argv)8 int main(int argc, char **argv)
9 {
10   wchar_t a[] = L"The spazzy orange tiger jumped over the tawny jaguar.";
11   wchar_t *b, *c;
12   wchar_t *d, *e;
13 
14   size_t l = wcslen (a);
15   fprintf (stderr, "wcslen: %zd\n", l); // wcslen: 53
16 
17   b = (wchar_t *) malloc((l + 1) * sizeof (wchar_t));
18   c = wcscpy (b, a);
19 
20   fprintf (stderr, "wcscmp equal: %d\n", wcscmp (a, b)); // wcscmp equal: 0
21 
22   d = wcsrchr (a, L'd');
23   e = wcschr (a, L'd');
24 
25   fprintf (stderr, "wcsrchr == wcschr: %d\n", d == e); // wcsrchr == wcschr: 1
26 
27   free (c); // b == c
28   return 0;
29 }
30