- Appends a copy of the source string to the destination string. The terminating null character in destination is overwritten by the first character of source, and a null-character is included at the end of the new string formed by the concatenation of both in destination. Destination and source shall not overlap. Parameters destination Pointer to the destination array, which should contain a C.
- Feb 13, 2017 In this video you can learn how calculate the length of a string without using string.h More Video Click Blog: http://programminurdu.blogspot.com/.
![Strcpy in cpp Strcpy in cpp](/uploads/1/2/6/1/126145923/203014129.jpg)
< cpp | string | byte
C++Language | ||||
Standard Library Headers | ||||
Freestanding and hosted implementations | ||||
Named requirements | ||||
Language support library | ||||
Concepts library(C++20) | ||||
Diagnostics library | ||||
Utilities library | ||||
Strings library | ||||
Containers library | ||||
Iterators library | ||||
Ranges library(C++20) | ||||
Algorithms library | ||||
Numerics library | ||||
Input/output library | ||||
Localizations library | ||||
Regular expressions library(C++11) | ||||
Atomic operations library(C++11) | ||||
Thread support library(C++11) | ||||
Filesystem library(C++17) | ||||
Technical Specifications |
Strcat prototype char. strcat( char. dest, const char. src ); The strcat function takes two arguments: dest and src.This function appends a copy of the character string pointed to by src to the end of string pointed to by dest.The null terminating character at the end of dest is replaced by the first character of src and the resulting character is also null terminated.
Null-terminated strings | ||||
Byte strings | ||||
Multibyte strings | ||||
Wide strings | ||||
Classes | ||||
(C++17) |
Functions | ||||||||||||||||||||||||||
Character manipulation | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
Conversions to numeric formats | ||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||
String manipulation | ||||||||||||||||||||||||||
String examination | ||||||||||||||||||||||||||
Memory manipulation | ||||||||||||||||||||||||||
Miscellaneous |
Defined in header <cstring> |
Copies the character string pointed to by
src
, including the null terminator, to the character array whose first element is pointed to by dest
.The behavior is undefined if the
dest
array is not large enough. The behavior is undefined if the strings overlap.Contents |
[edit]Parameters
dest | - | pointer to the character array to write to |
src | - | pointer to the null-terminated byte string to copy from |
[edit]Return value
dest
[edit]Example
Output:
[edit]See also
copies a certain amount of characters from one string to another (function)[edit] | |
copies one buffer to another (function)[edit] | |
C documentation for strcpy |
Retrieved from 'https://en.cppreference.com/mwiki/index.php?title=cpp/string/byte/strcpy&oldid=83465'
- Related Questions & Answers
- Selected Reading
CC++Programming
The function strcpy() is a standard library function. It is used to copy one string to another. In C language,it is declared in “string.h” header file while in C++ language, it is declared in cstring header file. It returns the pointer to the destination.
Here is the syntax of strcpy() in C language,
Some key points of strcpy().
- It copies the whole string to the destination string. It replaces the whole string instead of appending it.
- It won’t change the source string.
Here is an example of strcpy() in C language,