In C, how to copy a string into another string?
In C, the purpose of the strcpy()
(string copy) function is to copy a string into another:
char * strcpy( char * destination, const char * source );
Library: the strcpy() function needs the string.h library:
#include <string.h>
Note that the size of the destination string must be large enough to accommodate the copy.
Example :
// Source string
char src[] = "String to copy";
// Destination string
char dest[200];
// Copy src in dest
strcpy (dest, src);
Try online on repl.it.
In C, the purpose of the strcpy()
(string copy) function is to copy a string into another:
char * strcpy( char * destination, const char * source );
Library: the strcpy() function needs the string.h library:
#include <string.h>
Note that the size of the destination string must be large enough to accommodate the copy.
Example :
// Source string
char src[] = "String to copy";
// Destination string
char dest[200];
// Copy src in dest
strcpy (dest, src);
Try online on repl.it.
In C, the purpose of the strcpy()
(string copy) function is to copy a string into another:
char * strcpy( char * destination, const char * source );
Library: the strcpy() function needs the string.h library:
#include <string.h>
Note that the size of the destination string must be large enough to accommodate the copy.
Example :
// Source string
char src[] = "String to copy";
// Destination string
char dest[200];
// Copy src in dest
strcpy (dest, src);
Tester l'exemple en ligne sur repl.it.
In C, the purpose of the strcpy (string copy) function is to copy a string into another:
char * strcpy( char * destination, const char * source );
Library: this function needs the string.h library:
#include <string.h>
Note that the size of the destination string must be large enough to accommodate the copy.
Example :
// Source string
char src[] = "String to copy";
// Destination string
char dest[200];
// Copy src in dest
strcpy (dest, src);
Tester l'exemple en ligne sur repl.it.
# | ID | Query | URL | Count |
---|