strcpy
The strcpy function copies the content of a string into another string. It doesn't check if the destination string has enough space to receive the copy, so it should be used with care.
The strcpy function requires two arguments. The first argument is a pointer to the destination string. The second argument is a pointer to the source string.
The following code shows an example of strcpy use:
#include#include int main() { char *src = "source string"; char dest[50]; // destination string (notice that it must have enough space strcpy(dest, src); printf("the destination string is now '%s'\n", dest); return 0; }
Article created on 2008-08-19 22:15:45
Post a comment