adspace


Difference between strdup and strcpy?

Answer Posted / Kuldeep Garg

strcpy() is a C library function that copies the string pointed by src, including the terminating null character, into the array pointed by dest. It assumes that the destination array has enough space to store the source string plus one for the null character. On the other hand, strdup() returns a new string which is a duplicate of the original string pointed by src. It dynamically allocates memory for the new string and returns a pointer to it.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How c functions prevents rework and therefore saves the programers time as wel as length of the code ?

1164


What character terminates all character array strings a) b) . c) END

1394


daily Routine of father

1483


Can union be self referenced?

1265


What is the latest version on c++?

1205