Localization library | |||||||||||||||||||||||||
Regular expressions library(C++11) | |||||||||||||||||||||||||
Formatting library(C++20) | |||||||||||||||||||||||||
Null-terminated sequence utilities | |||||||||||||||||||||||||
Byte strings | |||||||||||||||||||||||||
Multibyte strings | |||||||||||||||||||||||||
Wide strings | |||||||||||||||||||||||||
Primitive numeric conversions | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
Text encoding identifications | |||||||||||||||||||||||||
|
Functions | ||||||||||||||||||||||||||||||||||||
Character classification | ||||||||||||||||||||||||||||||||||||
Character manipulation | ||||||||||||||||||||||||||||||||||||
Conversions to numeric formats | ||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||
String manipulation | ||||||||||||||||||||||||||||||||||||
String examination | ||||||||||||||||||||||||||||||||||||
Character array functions | ||||||||||||||||||||||||||||||||||||
Miscellaneous | ||||||||||||||||||||||||||||||||||||
Defined in header <cstring> | ||
char* strcpy(char* dest,constchar* src); | ||
Copies the character string pointed to bysrc, including the null terminator, to the character array whose first element is pointed to bydest.
The behavior is undefined if thedest array is not large enough. The behavior is undefined if the strings overlap.
Contents |
dest | - | pointer to the character array to write to |
src | - | pointer to the null-terminated byte string to copy from |
dest
#include <cstring>#include <iostream>#include <memory> int main(){constchar* src="Take the test.";// src[0] = 'M'; // can't modify string literalauto dst=std::make_unique<char[]>(std::strlen(src)+1);// +1 for null terminator std::strcpy(dst.get(), src); dst[0]='M';std::cout<< src<<'\n'<< dst.get()<<'\n';}
Output:
Take the test.Make the test.
copies a certain amount of characters from one string to another (function)[edit] | |
copies one buffer to another (function)[edit] | |
C documentation forstrcpy |