Difference between strdup and strcpy?

1 reply [Last post]
Last seen: 9 years 33 weeks ago
Joined: 2009-04-26
bOt Points: 153

Last seen: 10 years 21 weeks ago
Joined: 2009-03-20
bOt Points: 122
strcpy - copy a string to a

strcpy - copy a string to a location u created (u create the location, make sure that the source string will have enough room there and afterwards use strcpy to copy)

strdup - copy a string to a location that will be created by the function. The function will allocate space, make sure that your string will fit there and copy the string. Will return a pointer to the created area.