![]() |
INTRODUCTION:strcpy is a C standard library function that copies a string from one location to another. It is defined in the string.h header file. The function takes two arguments: a destination buffer where the copied string will be stored, and a source string that will be copied. The function copies the entire source string, including the null terminator, into the destination buffer. The C strcpy() function copies the content of a string to another. The content of the destination string will be replaced with that of the source string by the strcpy() function. It is defined inside <string.h> header file. Syntax: char* strcpy(char* destination, const char* source); Parameters: This method accepts the following parameters:
Return Value: A pointer to the destination string is returned after the strcpy() function copies the source string. Example: 1 C
Output
str1: Hello World! str2: Hello World! str3: Copy successful str4:GeeksForGeeks EXAMPLE 2 : C
Output
str1: Hello str2: Hello Important Points
ADVANTAGES AND DISADVANTAGES:Some advantages of using strcpy in C include: It is a simple and easy-to-use function that can be used to copy strings quickly and easily. However, there are also some disadvantages to consider when using strcpy: It does not check the size of the destination buffer, so it is possible to overwrite the buffer and cause a buffer overflow if the source string is longer than the destination buffer. This can lead to security vulnerabilities and other problems. |
Reffered: https://www.geeksforgeeks.org
C Language |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |