public static member function
<string>
std::char_traits::copystatic char_type* copy (char_type* dest, const char_type* src, size_t n);
Copy character sequence
Copies the sequence of n characters pointed by src to the array pointed by dest. Ranges shall not overlap.All character traits types shall implement the function as if the individual characters were assigned using member assign.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// char_traits::copy
#include <iostream> // std::cout
#include <string> // std::char_traits
int main ()
{
char foo[] = "test string";
char bar[20];
unsigned len = std::char_traits<char>::length(foo);
std::char_traits<char>::copy (bar,foo,len);
bar[len] = '\0'; // append null-character
std::cout << "foo contains: " << foo << '\n';
std::cout << "bar contains: " << bar << '\n';
return 0;
}
foo contains: test string bar contains: test string
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