strcpy in C++ Last Updated : 11 Jan, 2025 Comments Improve Suggest changes Like Article Like Report strcpy() is a standard library function in C++ and is used to copy one string to another. In C++ it is present in the <string.h> and <cstring> header files. Syntax: char* strcpy(char* dest, const char* src);Parameters: This method accepts the following parameters: dest: Pointer to the destination array where the content is to be copied.src: string which will be copied.Return Value: After copying the source string to the destination string, the strcpy() function returns a pointer to the destination string.The strcpy() function is used to copy strings in C++. Example: C++ // C++ program to illustrate // strcpy() function in C/C++ #include <iostream> #include <cstring> using namespace std; int main() { // Strings Declared char str1[] = "Hello Geeks!"; char str2[] = "GeeksforGeeks"; char str3[40]; char str4[40]; char str5[] = "GfG"; // String copy used strcpy(str2, str1); strcpy(str3, "Copy successful"); strcpy(str4, str5); // Strings Printed cout << "str1: " << str1 << "\nstr2: " << str2 << "\nstr3: " << str3 << "\nstr4: " << str4; return 0; } Outputstr1: Hello Geeks! str2: Hello Geeks! str3: Copy successful str4: GfGTime Complexity: O(n)Auxiliary Space: O(1)Important Points:This function copies the entire string to the destination string. It doesn't append the source string to the destination string. In other words, we can say that it replaces the content of the destination string with the content of the source string.It does not affect the source string. The source string remains the same after copying.This function only works with C style strings and not C++ style strings i.e. it only works with strings of type char str[]; and not string s1; which are created using standard string data type available in C++ and not C. Comment More infoAdvertise with us Next Article strcpy in C++ kartik Follow Improve Article Tags : C++ cpp-string Practice Tags : CPP Similar Reads strcat() in C C strcat() function appends the string pointed to by src to the end of the string pointed to by dest. It will append a copy of the source string in the destination string. plus a terminating Null character. The initial character of the string(src) overwrites the Null-character present at the end of 2 min read memcpy() in C The memcpy() function in C is defined in the <string.h> header is a part of the standard library in C. The memcpy() function is used to copy a block of memory from one location to another. Example: C#include <stdio.h> #include <string.h> // For memcpy int main() { // Initialize a v 2 min read Tuples in C++ A tuple is an object that can hold a number of elements. The elements can be of different data types. The elements of tuples are initialized as arguments in order in which they will be accessed. Tuples are a versatile data structure for grouping values. To understand how to use tuples in C++ and the 5 min read string at() in C++ The std::string::at() in C++ is a built-in function of std::string class that is used to extract the character from the given index of string. In this article, we will learn how to use string::at() in C++.Syntaxstr.at(idx)Parametersidx: Index at which we have to find the character.Return ValueReturn 1 min read History of C++ The C++ language is an object-oriented programming language & is a combination of both low-level & high-level language - a Middle-Level Language. The programming language was created, designed & developed by a Danish Computer Scientist - Bjarne Stroustrup at Bell Telephone Laboratories ( 7 min read Like