+ 2

C++

could someone tell me what is the meaning of (strcpy) and what is its function?

19th Dec 2017, 1:03 PM
RiGeL
RiGeL - avatar
2 Answers
+ 10
char * strcpy ( char * destination, const char * source ); it's function is to copy the 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 destinationshall be long enough to contain the same C string as source(including the terminating null character), and should not overlap in memory with source.ex:- #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; }
19th Dec 2017, 1:21 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 1
@Gawen thank you alot
19th Dec 2017, 1:30 PM
RiGeL
RiGeL - avatar