wcslen() function in C++ with Examples
The wcslen() function is defined in cwchar.h header file. The function wcslen() function returns the length of the given wide string.
Syntax:
size_t wcslen(const wchar_t* str);
Parameter: This method takes a single parameter str which represents the pointer to the wide string whose length is to be calculated.
Return Value: This function returns the length of wide string.
Below programs illustrate the above function:-
Example 1:-
// c++ program to demonstrate // example of wcslen() function. #include <bits/stdc++.h> using namespace std; int main() { // Get the string to be used wchar_t str[] = L"geeks"; // Get the length of the string using wcslen() wcout << L"The length of '" << str << L"' is =" << wcslen(str) << endl; return 0; } |
The length of 'geeks' is =5
Example 2:-
// c++ program to demonstrate // example of wcslen() function. #include <bits/stdc++.h> using namespace std; int main() { // Get the string to be used wchar_t str[] = L"A computer science portal for geeks"; // Get the length of the string using wcslen() wcout << L"The length of '" << str << L"' is =" << wcslen(str) << endl; return 0; } |
The length of 'A computer science portal for geeks' is =35
=
Recommended Posts:
- Can we call an undeclared function in C++?
- Can we use function on left side of an expression in C and C++?
- Declare a C/C++ function returning pointer to array of integer pointers
- Function overloading and return type
- Default arguments and virtual function
- Function overloading and const keyword
- How to measure time taken by a function in C?
- Comparator function of qsort() in C
- Can we access private data members of a class without using a member or a friend function?
- Function Overloading and float in C++
- Extra brackets with function names in C/C++
- Function Interposition in C with an example of user defined malloc()
- A C/C++ Function Call Puzzle
- std::tuple, std::pair | Returning multiple values from a function using Tuple and Pair in C++
- Bind function and placeholders in C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



