A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/cstring/strcpy/ below:

function

<cstring>

strcpy
char * strcpy ( char * destination, const char * source );

Copy string

Copies the C string pointed by source into the array pointed by destination, including the terminating null character (and stopping at that point).

To avoid overflows, the size of the array pointed by destination shall be long enough to contain the same C string as source (including the terminating null character), and should not overlap in memory with source.



Parameters
destination
Pointer to the destination array where the content is to be copied.
source
C string to be copied.

Return Valuedestination is returned.

Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* strcpy example */
#include <stdio.h>
#include <string.h>

int main ()
{
  char str1[]="Sample string";
  char str2[40];
  char str3[40];
  strcpy (str2,str1);
  strcpy (str3,"copy successful");
  printf ("str1: %s\nstr2: %s\nstr3: %s\n",str1,str2,str3);
  return 0;
}

Output:
str1: Sample string
str2: Sample string
str3: copy successful


See also
strncpy
Copy characters from string (function)
memcpy
Copy block of memory (function)
memmove
Move block of memory (function)
memchr
Locate character in block of memory (function)
memcmp
Compare two blocks of memory (function)
memset
Fill block of memory (function)

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