Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::wcscpy(3)		      C++ Standard Libary		std::wcscpy(3)

NAME
       std::wcscpy - std::wcscpy

Synopsis
	  Defined in header <cwchar>
	  wchar_t *wcscpy( wchar_t *dest, const	wchar_t	*src );

	  Copies  the wide string pointed to by	src (including the terminating
       null wide
	  character) to	wide character array pointed to	by dest.

	  If the strings overlap, the behavior is undefined.

Parameters
	  dest - pointer to the	wide character array to	copy to
	  src  - pointer to the	null-terminated	wide string to copy from

Return value
	  dest

Example
       // Run this code

	#include <iostream>
	#include <cwchar>
	#include <memory>
	#include <clocale>

	int main()
	{
	    const wchar_t* src = L" means dog";
	//  src[0] = L''; // can't modify string literal
	    auto dst = std::make_unique<wchar_t[]>(std::wcslen(src)+1);	//  +1
       for the null
	    std::wcscpy(dst.get(), src);
	    dst[0] = L'';
	    std::setlocale(LC_ALL, "en_US.utf8");
	    std::wcout.imbue(std::locale(""));
	    std::wcout << src << '\n' << dst.get() << '\n';
	}

Output:
	 means dog
	 means dog

See also
	  wcsncpy  copies  a certain amount of wide characters from one	string
       to another
		  (function)
		  copies a certain amount of wide characters between two  non-
       overlapping
	  wmemcpy arrays
		  (function)
	  strcpy  copies one string to another
		  (function)

http://cppreference.com		  2022.07.31			std::wcscpy(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::wcscpy&sektion=3&manpath=FreeBSD+Ports+15.0>

home | help