A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/string/to_wstring/ below:

function

<string>

std::to_wstring
wstring to_wstring (int val);wstring to_wstring (long val);wstring to_wstring (long long val);wstring to_wstring (unsigned val);wstring to_wstring (unsigned long val);wstring to_wstring (unsigned long long val);wstring to_wstring (float val);wstring to_wstring (double val);wstring to_wstring (long double val);

Convert numerical value to wide string

Returns a wstring with the representation of val.

The format used is the same that wprintf would print for the corresponding type:


type of val wprintf equivalent description int L"%d" Decimal-base representation of val.
The representations of negative values are preceded with a minus sign (-). long L"%ld" long long L"%lld" unsigned L"%u" Decimal-base representation of val. unsigned long L"%lu" unsigned long long L"%llu" float L"%f" As many digits are written as needed to represent the integral part, followed by the decimal-point character and six decimal digits.
inf (or infinity) is used to represent infinity.
nan (followed by an optional sequence of characters) to represent NaNs (Not-a-Number).
The representations of negative values are preceded with a minus sign (-).
double L"%f" long double L"%Lf"
Parameters
val
Numerical value.

Return Value A wstring object containing the representation of val as a sequence of characters.

Example
1
2
3
4
5
6
7
8
9
10
11
12
// to_wstring example
#include <iostream>   // std::wcout
#include <string>     // std::wstring, std::to_wstring

int main ()
{
  std::wstring pi = L"pi is " + std::to_wstring(3.1415926);
  std::wstring perfect = std::to_wstring(1+2+4+7+14) + L" is a perfect number";
  std::wcout << pi << L'\n';
  std::wcout << perfect << L'\n';
  return 0;
}

Possible output:
pi is 3.141593
28 is a perfect number


Exceptions The wstring constructor may throw.

See also
swprintf
Write formatted data to wide string (function)
to_string
Convert numerical value to string (function)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4