A pointer to a wide-character string, where each element is of type `wchar_t`. Used for representing text in wide-character encoding to support extended character sets.
1st Parameter
Pointer to the wide-character string buffer where the formatted date and time will be stored. The buffer must be large enough to hold the resulting string, including the null terminator.
2nd Parameter Type : size_t
Platform-specific unsigned type for array indices and memory sizes.
2nd Parameter
The maximum number of wide characters (including the null terminator) that can be written to `ws`.
3rd Parameter Type : const wchar_t *
A pointer to a read-only wide-character string, where each character is of type `wchar_t`. Used for representing text in wide-character encoding to support extended character sets, such as Unicode. The string is null-terminated, with the terminator being a `wchar_t` with value 0.
3rd Parameter
Pointer to a null-terminated wide-character string specifying the format to use for formatting the date and time. It can include specifiers like `%Y`, `%m`, `%d`, etc.
4th Parameter Type : const struct tm *
Pointer to a constant `struct tm`, which represents broken-down time values including year, month, day, hour, minute, and second.
4th Parameter
Pointer to a `struct tm` object containing the date and time information to be formatted.
Read more about parameters of wcsftime in parameters section
The wcsftimefunction in C language Formats the time and date as a wide character string according to the locale settings and format string.
wcsftime converts the time information from a given calendar time (struct tm) into a wide character string according to a specified format. It is the wide character equivalent of strftime. The function uses the current locale settings for formatting.
The wcsftimefunction takes 4
parameters:
•
wchar_t * `ws`: Pointer to the wide-character string buffer where the formatted date and time will be stored. The buffer must be large enough to hold the resulting string, including the null terminator.
•
size_t `maxsize`: The maximum number of wide characters (including the null terminator) that can be written to `ws`.
•
const wchar_t * `format`: Pointer to a null-terminated wide-character string specifying the format to use for formatting the date and time. It can include specifiers like `%Y`, `%m`, `%d`, etc.
•
const struct tm * `timeptr`: Pointer to a `struct tm` object containing the date and time information to be formatted.
Formats the date and time information from `timeptr` into the wide-character string `ws` according to the format specified by `format`. Writes at most `maxsize` wide characters, including the null terminator. Returns the number of wide characters written to `ws` (excluding the null terminator) or 0 if the resulting string exceeds `maxsize`.
The wcsftime function return value :
Returns the number of wide characters placed in the array wcs if the total number including the terminating null wide character is not more than maxsize
Otherwise, it returns 0, and the contents of the array are indeterminate
Output
This example demonstrates the basic usage of wcsftime to format the current date and time as a wide character string.