wcswcs() — Locate Wide-Character Substring
Format
#include <wchar.h>
wchar_t *wcswcs(const wchar_t *string1, const wchar_t *string2);Language Level
XPG4
Threadsafe
Yes
Wide Character Function
See Wide Characters for more information.
Description
The wcswcs() function
locates the first occurrence of string2 in
the wide-character string pointed to by string1.
In the matching process, the wcswcs() function
ignores the wchar_t null character that ends string2.
Return Value
The wcswcs() function
returns a pointer to the located string or NULL if the string
is not found. If string2 points to a string
with zero length, wcswcs() returns string1.
Example
This example finds the first occurrence
of the wide character string pr in buffer1.
#include <stdio.h>
#include <wchar.h>
#define SIZE 40
int main(void)
{
wchar_t buffer1[SIZE] = L"computer program";
wchar_t * ptr;
wchar_t * wch = L"pr";
ptr = wcswcs( buffer1, wch );
printf( "The first occurrence of %ls in '%ls' is '%ls'\n",
wch, buffer1, ptr );
}
/**************** Output should be similar to: ******************
The first occurrence of pr in 'computer program' is 'program'
*/
Related Information
- strchr() — Search for Character
- strcspn() — Find Offset of First Character Match
- strpbrk() — Find Characters in String
- strrchr() — Locate Last Occurrence of Character in String
- strspn() — Find Offset of First Non-matching Character
- strstr() — Locate Substring
- wcschr() — Search for Wide Character
- wcscmp() — Compare Wide-Character Strings
- wcscspn() — Find Offset of First Wide-Character Match
- wcspbrk() — Locate Wide Characters in String
- wcsrchr() — Locate Last Occurrence of Wide Character in String
- wcsspn() — Find Offset of First Non-matching Wide Character
- <wchar.h>