By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,515 Members | 1,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,515 IT Pros & Developers. It's quick & easy.

can you tell the diff between strcpy and memcpy?

P: 13
Can u please tell me the difference between strcpy() and memcpy().
Jun 20 '07 #1
Share this Question
Share on Google+
2 Replies


weaknessforcats
Expert Mod 5K+
P: 9,197
strcpy() copies bytes until it reaches a 0 byte.
memcpy() copies memory based on the size argument regarless of contents.
Jun 20 '07 #2

vpawizard
P: 66
Hello,
Another less obvious but often overlooked difference is,
strcpy() - The strings may not overlap, and the destination string dest must be large enough to receive the copy.
memcpy()- If copying takes place between objects that overlap, the behaviour is undefined.


(P.S. - This problem ate up my whole day to figure it out)
Jun 23 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.